Is there any difference between: window.localStorage and localStorage?

后端 未结 5 683
执笔经年
执笔经年 2021-01-07 17:46

I have been doing the following:

var store = window.localStorage;
store.setItem()

but now I see code doing this:

localStora         


        
5条回答
  •  醉话见心
    2021-01-07 18:27

    Unless you've declared a variable named localStorage in a custom defined scope, they're the same. localStorage refers to window.localStorage. In fact every variable in global namespace can be accessed as window.

    For example:

    
    

提交回复
热议问题