码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript的Function Scope and Lexical Scope

时间:2015-05-17 18:24:26      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

原贴地址:http://pierrespring.com/2010/05/11/function-scope-and-lexical-scoping/

个人觉得写得不错,简单地搬运,如有错误,请指正。

 

Wikipedia defines Scope as follows:

  Tipically, scope is used to define the extent of information hiding--that is, the visibility or accessibility of

  variables from diefferent parts of the program.

  作用域是用来定义信息隐藏的深度--程序中,其它地方对某个部分中的变量的可访问性。

In JavaScript we have Function Scope and Lexical Scope.

Function Scope means that any variable which is defined within a function is visible within that entire function.

This is quite different form Block Scope, in which a variable scope is limited by the block a variable is declared in.

Function Scope 是指,任何在函数内部定义的变量是对整个函数都可见的。

 

JavaScript的Function Scope and Lexical Scope

标签:

原文地址:http://www.cnblogs.com/Yaxian/p/4510030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!