文章列表
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 ...
- 2009-01-08 13:55
- 浏览 723
- 评论(0)
//
// 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. ...
- 2009-01-07 13:43
- 浏览 867
- 评论(0)
//
// 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 ...
- 2009-01-07 13:13
- 浏览 758
- 评论(0)
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.
- 2009-01-07 00:42
- 浏览 758
- 评论(0)
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 ...
- 2009-01-07 00:39
- 浏览 803
- 评论(0)
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 ...
- 2009-01-07 00:02
- 浏览 663
- 评论(0)
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 ...
- 2009-01-06 23:06
- 浏览 786
- 评论(0)
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 ...
- 2009-01-06 21:50
- 浏览 700
- 评论(0)
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 ...
- 2009-01-06 21:09
- 浏览 765
- 评论(0)
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 ...
- 2009-01-05 22:11
- 浏览 565
- 评论(0)
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 ...
- 2009-01-05 22:00
- 浏览 763
- 评论(0)
JavaScript calls this
method automatically if an object is used in a context where a primitive value is required.
- 2009-01-05 18:05
- 浏览 739
- 评论(0)
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 ...
- 2009-01-05 18:02
- 浏览 850
- 评论(0)
[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 ...
- 2009-01-05 17:51
- 浏览 787
- 评论(0)
[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]
- 2009-01-05 00:29
- 浏览 784
- 评论(0)