Problem Statement
Which statement about localStorage is true?
Explanation
localStorage allows web applications to store key-value data in the browser that persists even after the page reloads or the browser restarts. It is limited to around 5MB and only stores string values. For temporary data, sessionStorage can be used instead. It’s useful for caching user preferences or session data offline.
Code Solution
SolutionRead Only
<!-- Example using localStorage -->
<script>
localStorage.setItem('username', 'John');
const user = localStorage.getItem('username');
console.log('Welcome, ' + user);
</script>