javascript - local storage not accepting value from object -


im trying set x's age local storage item 'age' however, reason not know, not work.

here code:

var x = { age: 37, gender: "male", income: 17000, }; localstorage.setitem("age") = x.age; alert(localstorage.getitem('age')); 

the problem syntax. need use way.

localstorage.setitem("age", x.age)  alert(localstorage.getitem('age')); 

the idea simple. storing data against name. , retrieve using same name.


Comments