OO [removed] Definitive explanation of variable scope

前端 未结 3 773
夕颜
夕颜 2020-12-02 14:40

Can someone provide an explanation of variable scope in JS as it applies to objects, functions and closures?

3条回答
  •  天涯浪人
    2020-12-02 15:30

    Variables not declared with var are global in scope. Functions introduce a scope, but note that if blocks and other blocks do not introduce a scope.

    I could also see much information about this by Googling Javascript scope. That's really what I would recommend. http://www.digital-web.com/articles/scope_in_javascript/

提交回复
热议问题