javascript-questions
javascript-questions copied to clipboard
Question 22: incorrect answer / incomplete choice
- How long is cool_secret accessible?
sessionStorage.setItem('cool_secret', 123);
- A: Forever, the data doesn't get lost.
- B: When the user closes the tab.
- C: When the user closes the entire browser, not only the tab.
- D: When the user shuts off their computer.
Answer B: The data stored in sessionStorage is removed after closing the tab.
The answer is incorrect. Data is not removed after closing the tab. For example, when you restore your tab (using cmd + shift + T
), data in sessionStorage
restored as well. It's removed after the session ended.
I suggest changing the question altogether instead of asking how long the data is accessible.