js check if local storage is not empty code example Example: how to check if local storage variable exists in javascript if (localStorage.getItem("username") === null) { //... }