js check if sessionstorage key exists code example Example: local storage check if key exists if (localStorage.getItem("username") === null) { //... }