|
此文章由 o2h2o 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 o2h2o 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 乱码 于 2010-11-17 11:33 发表 ![](http://www.oursteps.com.au/bbs/images/common/back.gif)
看了一下,在39页,他没做详细的解释.
在javascript good parts上面function/closure那一章也有这个例子,早晨翻出来看了一下,Douglas也没做深入的解释。
在用chrome debug那个function的时候,能明显的看到closure显示是0/ ...
Using this executed anonymous function as a wrapper for the for loop (replacing the existing {...}
braces) we can now enforce that the correct value will be enclosed by these handlers. Note that, in order to
achieve this, we pass in the iterator value to the anonymous function and then re-declare it in the arguments.
This means that within the scope of each step of the for loop the i variable is defined a new, giving our
click handler closure the value that it expects.
在深入解释 至于内存的分布图 估计 研究javascrpit 人不会太在意吧
[ 本帖最后由 o2h2o 于 2010-11-17 12:01 编辑 ] |
|