The question says it all. I realize that all options do work in up-to-date browsers, but what is the semantically best choice, and why?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Good question. According to W3C standards, the correct is window.localStorage because the localStorage attribute is part of window object. And it is not a function, it is an attribute.
Source: http://dev.w3.org/html5/webstorage/#dom-localstorage Example: http://www.rajdeepd.com/articles/chrome/localstrg/LocalStorageSample.htm