Victor Kimura
asked on
how to use Javascript's localStorage.getItem()
Hi,
I'm wondering how I'm supposed to use the localStorage. I have this bit of code:
The console.log doesn't show anything. This:
console.log( car );
just shows [Object object]
This:
console.log( localStorage.getItem( 'car.doors' ) );
comes out null
The .each doesn't step through.
What am I missing?
Thank you!
I'm wondering how I'm supposed to use the localStorage. I have this bit of code:
var car = {};
car.wheels = 4;
car.doors = 2;
car.sound = 'vroom';
car.name = 'Lightning McQueen';
console.log( car );
localStorage.setItem( 'car', car );
console.log( localStorage.getItem( 'car.doors' ) );
var oCars = localStorage.getItem( 'car' );
$.each(oCars, function(key, value) {
var sCurVal = oCars[key];
});
The console.log doesn't show anything. This:
console.log( car );
just shows [Object object]
This:
console.log( localStorage.getItem( 'car.doors' ) );
comes out null
The .each doesn't step through.
What am I missing?
Thank you!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Cathal! That works! =)
ASKER
I got that code from some site. Forgot where though
can you give me an example? =)
thanks!