开发者

Store booleans in javascript's localStorage? [duplicate]

开发者 https://www.devze.com 2023-03-28 15:55 出处:网络
This question already has answers here: Closed 11 years 开发者_如何学运维ago. Possible Duplicate:
This question already has answers here: Closed 11 years 开发者_如何学运维ago.

Possible Duplicate:

Cannot set boolean values in LocalStorage?

So i've been trying to get localStorage.test to store a boolean forever...

http://jsfiddle.net/abhi/aVmyt/

And it always ends up storing as a string.

Play around with the various localStorage variables created in the fiddle by changing the condition used in the if statement, and do lemme know if you manage to store a boolean...


The W3C Storage interface specifies that values (and keys) are strings:

Each Storage object provides access to a list of key/value pairs, which are sometimes called items. Keys are strings. Any string (including the empty string) is a valid key. Values are similarly strings

0

精彩评论

暂无评论...
验证码 换一张
取 消