How do I work with local storage

Keywords: local storage, JavaScript, web storage, client-side storage
Description: This section provides examples and explanations on how to use local storage in JavaScript for storing data on the user's browser.
        
            // Storing data in local storage
            localStorage.setItem('key', 'value');

            // Retrieving data from local storage
            var value = localStorage.getItem('key');
            console.log(value); // Output: value

            // Removing data from local storage
            localStorage.removeItem('key');

            // Clearing all local storage data
            localStorage.clear();
        
    

Keywords: local storage JavaScript web storage client-side storage