Question 14
Consider the following JavaScript code snippet where a web application manages user preferences using localStorage. A user opens the application, sets their theme preference to "dark", refreshes the page once, closes the browser tab, and opens a new tab to reload the page. What will be the behavior of the theme preference?
The theme will be lost because closing the browser tab clears localStorage
The theme will be preserved as "dark" because localStorage persists across browser sessions
The theme will be undefined because localStorage is cleared on refresh
The theme will be reset to "light" when a new tab is opened