易截截图软件、单文件、免安装、纯绿色、仅160KB

Javascript Closures

Javascript Closures
Introduction
The Resolution of Property Names on Objects
Assignment of Values
Reading of Values
Identifier Resolution, Execution Contexts and Scope Chains
The Execution Context
Scope chains and [[scope]]
Identifier Resolution
Closures
Automatic Garbage Collection
Forming Closures
What can be done with Closures?
Example 1: setTimeout with Function References
Example 2: Associating Functions with Object Instance Methods
Example 3: Encapsulating Related Functionality
Other Examples
Accidental Closures
The Internet Explorer Memory Leak Problem
Introduction
Closure A "closure" is an expression (typically a function) that can have free variables together with an environment that binds those variables (that "closes" the expression).
Closures are one of the most powerful features of ECMAScript (javascript) but they cannot be property exploited without understanding them. They are, however, relatively easy to create, even accidentally, and their creation has potentially harmful consequences, particularly in some relatively common web browser environments. To avoid accidentally encountering the drawbacks and to take advantage of the benefits they offer it is necessary to understand their mechanism. This depends heavily on the role of scope chains in identifier resolution and so on the resolution of property names on objects.
The simple explanation of a Closure is that ECMAScript allows inner functions; function definitions and function expressions that are inside the function bodes of other functions. And that those inner functions are allowed access to all of the local variables, parameters and declared inner functions within their outer function(s). A closure is formed when one of those inner functions is made accessible outside of the function in which it was contained, so that it may be executed after the outer function has returned. At which point it still has access to the local variables, parameters and inne


相关文档:

JavaScript 获取对象的高度和宽度详细说明

scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......

JavaScript 未结束的字符串常量

JavaScript 未结束的字符串常量
做JavaScript的时候,发现老是出现错误:“未结束的字符串常量”.
自己找了下应该是传参数的时候,有特殊字符引起的.
网上也找了下,也有好多出现这种情况.做下总结,以方便以后查阅.
1.JAVASCRIPT引用时,使用的字符语言不一致.
比如:<script type=”text/javascrip ......

javascript将字符串类型转换为XML对象

try { //Internet Explorer
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(data);
} catch(e) { //Other Browsers
parser=new DOMParser();
xmlDoc=parser.parsefromString(data,"text/xml");
} ......

[JAVASCRIPT] IFRAME VS AJAX 异步提交

在ajax没出来之前,一直是用iframe实现的无刷新请求。
主要的原理是:
使用js创建一个隐藏的iframe
把要提交的表单的target属性指向1中生成的iframe
在请求的页面中回调父页面的方法
这样就实现了一个简单的“异步提交”
看起来和ajax一样的效果,那为什么还要有ajax,我们来比较下:(以下把ajax技术称为X ......

href=“#”与href=“javascript:void(0)”区别

使用过ajax的都常见这样的代码:
<a href="javascript:doTest2();void(0);" mce_href="javascript:doTest2();void(0);">here</a>
但这儿的void(0)究竟是何含义呢?
Javascript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值。
void 操作符用法格式如下:
1. javascript:void (expres ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号