UpTest > Web Development > HTML5 Test

Test: HTML5 Test

Question 1: Prev Next Hide answers
Which of the following is the correct way to store an object in localStorage?

var obj = { 'one': 1, 'two': 2, 'three': 3 };
localStorage.setItem('testObject', JSON.parse(testObject));
1 votes
localStorage.setItem('obj', obj);
0 votes
localStorage.setItem('obj', JSON.stringify(obj));
5 votes
localStorage.setItem(obj);
0 votes
Please login to submit your answer.