`
pstinghua
  • 浏览: 24205 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
The Function.apply( ) method is missing in Microsoft Internet Explorer 4 and 5. This is a pretty important function, and you may see code like this to replace it:   // IE 4 & 5 don't implement Function.apply( ). // This workaround is based on code by Aaron Boodman. if (!Function.prototype.apply ...
// // This function implements a breakpoint. It repeatedly prompts the user // for an expression, evaluates it with the supplied self-inspecting closure, // and displays the result. It is the closure that provides access to the // scope to be inspected, so each function must supply its own closure. ...
// // This function adds property accessor methods for a property with // the specified name to the object o. The methods are named get<name> // and set<name>. If a predicate function is supplied, the setter // method uses it to test its argument for validity before storing it. // If t ...
the new operator creates a new object and then invokes the constructor function, passing the newly created object as the value of the this keyword.
When a function is invoked as a function rather that as a method, the this keyword refers to the global object. Confusingly, this is true even when a nested function is invoked (as a function) within a containing method that was invoked as a method: the this keyword has one value in the containing fu ...
In addition to its array elements, the Arguments object defines a callee property that refers to the function that is currently being executed. This property is rarely useful, but it can be used to allow unnamed functions to invoke themselves recursively. For instance, here is an unnamed function lit ...
The Arguments object has one very unusual feature. When a function has named arguments, the array elements of the Arguments object are synonyms for the local variables that hold the function arguments. The arguments[] array and the named arguments are two different ways of referring to the same varia ...
Although function literals create unnamed functions, the syntax allows a function name to be optionally specified, which is useful when writing recursive functions that call themselves. For example: var f = function fact(x) { if (x <= 1) return 1; else return x*fact(x-1); };   This line of code ...
Nested functions may be defined only at the top level of the function within which they are nested. That is, they may not be defined within statement blocks, such as the body of an if statement or while loop.[*] Note that this restriction applies only to functions defined with the function statement ...
The delete operator sets an array element to the undefined value, but the element itself continues to exist. To actually delete an element, so that all elements above it are shifted down to lower indexes, you must use an array method. Array.shift() deletes the first element of an array, Array.pop() d ...
Note that array indexes must be integers greater than or equal to 0 and less than 232 -1. If you use a number that is too large, a negative number, or a floating-point number (or a boolean, an object, or other value), JavaScript converts it to a string and uses the resulting string as the name of a ...
                                                                                  JavaScript calls this method automatically if an object is used in a context where a primitive value is required.
In ECMAScript v3 and JavaScript 1.5, the Object class defines a toLocaleString() method in addition to its toString() method. The purpose of this method is to return a localized string representation of the object. The default toLocaleString() method defined by Object doesn't do any localization itse ...
[size=medium]Since constructor functions define new categories or classes of objects, the constructor property can help determine the type of an object. For example, you might use code like the following to determine the type of an unknown value: if ((typeof o == "object") && (o.con ...
[size=medium]When you intentionally use the empty statement, it is a good idea to comment your code in a way that makes it clear that you are doing it on purpose. For example: for(i=0; i < a.length; a[i++] = 0) /* Empty */ ;[/size]
Global site tag (gtag.js) - Google Analytics