JavaScript · Junior · Question 45 of 75

What does localStorage.getItem('n') return after localStorage.setItem('n', 5)?

Explanation

Web Storage stores only strings - the value is converted with String(). An object becomes '[object Object]', so complex data is saved with JSON.stringify and read with JSON.parse.

Further reading

Problem with a question

JavaScript · Junior · question 45

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz