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

[翻译]High Performance JavaScript(014)

Recursion Patterns  递归模式
    When you run into a call stack size limit, your first step should be to identify any instances of recursion in the code. To that end, there are two recursive patterns to be aware of. The first is the straightforward recursive pattern represented in the factorial() function shown earlier, when a function calls itself. The general pattern is as follows:
    当你陷入调用栈尺寸限制时,第一步应该定位在代码中的递归实例上。为此,有两个递归模式值得注意。首先是直接递归模式为代表的前面提到的factorial()函数,即一个函数调用自身。其一般模式如下:
function recurse(){
  recurse();
}
recurse();
    This pattern is typically easy to identify when errors occur. A second, subtler pattern involves two functions:
    当发生错误时,这种模式比较容易定位。另外一种模式称为精巧模式,它包含两个函数:
function first(){
  second();
}
function second(){
  first();
}
first();
    In this recursion pattern, two functions each call the other, such that an infinite loop is formed. This is the more troubling pattern and a far more difficult one to identify in large code bases.
    在这种递归模式中,两个函数互相调用对方,形成一个无限循环。这是一个令人不安的模式,在大型代码库中定位错误很困难。
    Most call stack errors are related to one of these two recursion patterns. A frequent cause of stack overflow is an incorrect terminal condition, so the first step after identifying the pattern is to validate the terminal condition. If the terminal condition is correct, then the algorithm contains too much recursion to safely be run in the browser and should be changed to use iteration, memoization, or both.
    大多数调用栈错误与这两种模式之一有关。常见的栈溢出原因是一个不正确的终止条件,所以定位模式错误的第一步是验证终止条件。如果终止条件是正确的,那么算法包含了太多层递归,为了能够安全地在浏览器中运行,应当改用迭代,制


相关文档:

ASP.NET中前台javascript与后台代码调用

C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中 ......

Javascript闭包(Closure)

Closure中文翻译为闭包.字面上来理解就是"封闭的包".(这是一句废话)
闭包是什么?
书面解释为:
所谓“闭包”,指的是一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分。
我认为闭包就是能够读/写函数内部的某些变量的子函数,并将这些变量保存 ......

javascript动态装入XML数据


使用javascript创建Microsoft XML DOM,就可以完成这一工作.
// 装入数据.
var source = new ActiveXObject("Microsoft.XMLDOM");
source.async = false
source.load("history.xml");
// 装入样式表.
var stylesheet = new ActiveXObject("Microsoft.XMLDOM");
stylesheet.async = false
stylesheet.load( ......

[翻译]High Performance JavaScript(012)

第四章  Algorithms and Flow Control  算法和流程控制
    The overall structure of your code is one of the main determinants as to how fast it will execute. Having a very small amount of code doesn't necessarily mean that it will run quickly, and having a large amount of code ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号