how to check key exist in local storage code example Example: local storage check if key exists if (localStorage.getItem("username") === null) { //... }