3
其中first results from a Google search的說,這個語法是用於localStorage的:localStorage的分配與setItem()
localStorage.lastname="Smith";
MDN使用.setItem()和.getItem(),我想是這樣,如果瀏覽器不支持localStorage,那麼你可以使用technique defined there來添加它。
但因爲我的程序僅在iOS上運行,我想我的問題是:
它是確定使用
localStorage.lastname="Smith";
代替:
window.localStorage.setItem("lastname","Smith");
嗯,我不會相信w3schools,尤其是當涉及到最佳實踐時...... –
如果您只關心一個操作系統,爲什麼不簡單地在該操作系統上進行測試。這將消除對第三方來源的準確性的任何懷疑。 –
我會遵循規範:http://www.w3.org/TR/webstorage/#storage如果設備不支持該規範,那麼我會使用一個polyfill來保持我的代碼與規範一致。 –