📅  最后修改于: 2022-03-11 15:02:26.735000             🧑  作者: Mango
// Create a function to load localStorage.
const loadLocalStorage = function () {
const storage = localStorage.getItem("keyName");
// Check if it's exists which means (there is a value).
if (storage) return JSON.parse(storage);
// If there is no value then return a message.
if (!storage) return "Key doesn't exist or Empty LocalStorage!";
};
// Store the value returned from the function in a variable.
const myStorage = loadLocalStorage();
// Log to the console the value returned from the function.
console.log(myStorage);