- 博客(31)
- 收藏
- 关注
原创 Extending Built-in Types
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 F...
2009-01-08 13:55:44
193
原创 Breakpoints using closures
// // 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 closur...
2009-01-07 13:43:20
136
原创 Private properties with closures
// // 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 i...
2009-01-07 13:13:37
146
原创 Constructor Functions
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:43
243
原创 Functions as Methods
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 ...
2009-01-07 00:39:40
177
原创 The callee Property
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 al...
2009-01-07 00:02:42
137
原创 Variable-Length Argument Lists: The Arguments Obje
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...
2009-01-06 23:06:39
147
原创 Function Literals
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: ...
2009-01-06 21:50:51
181
原创 Nested Functions
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 whi...
2009-01-06 21:09:11
234
原创 Deleting Array Elements
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 inde...
2009-01-05 22:11:51
185
原创 Reading and Writing Array Elements
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...
2009-01-05 22:00:44
134
原创 The valueOf() Method
[size=medium] JavaScript calls this method automatically if an object is used in a context where a primitive value is ...
2009-01-05 18:05:38
167
原创 The toLocaleString() Method
[size=medium]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 r...
2009-01-05 18:02:34
254
原创 The constructor Property
[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 follo...
2009-01-05 17:51:51
152
原创 the empty statement
[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: [code="javascript"]for...
2009-01-05 00:29:39
167
原创 with
[size=medium]The with statement is used to temporarily modify the scope chain. It has the following syntax: [code="javascript"] with (object) statement[/code] This statement effectively adds ob...
2009-01-05 00:27:26
127
原创 try/catch/finnaly
[size=medium] If control leaves the try block because of a return , continue , or break statement, the finally block is executed before control transfers to its new destination. If a finally bloc...
2009-01-05 00:17:54
185
原创 throw
[size=medium]The tHRow statement has the following syntax: throw expression; expression may evaluate to a value of any type. Commonly, however, it is an Error object or an instance of one of the su...
2009-01-04 23:56:59
124
原创 return
[size=medium]If a function executes a return statement with no expression , or if it returns because it reaches the end of the function body, the value of the function-call expression is undefined . ...
2009-01-04 23:52:37
152
原创 functions
[size=medium]Technically speaking, the function statement is not a statement. Statements cause dynamic behavior in a JavaScript program, while function definitions describe the static structure of a ...
2009-01-04 23:48:51
106
原创 Labels
[size=medium]Label names are distinct from variable and function names, so you do not need to worry about name collisions if you give a label the same name as a variable or function. When break i...
2009-01-04 23:01:58
156
原创 for/in loop
[size=medium]JavaScript arrays are simply a specialized kind of object. Therefore, the for/in loop enumerates array indexes as well as object properties. The for/in loop does not specify the order...
2009-01-04 22:53:05
183
原创 switch
[size=medium]The switch statement first evaluates the expression that follows the switch keyword and then evaluates the case expressions, in the order in which they appear, until it finds a value tha...
2009-01-04 20:39:59
129
原创 Local Variables: The Call Object
[size=medium] If global variables are properties of the special global object, then what are local variables? They too are properties of an object. This object is known as the call object . The call...
2009-01-02 23:33:23
139
原创 The Global Object
[size=medium] When the JavaScript interpreter starts up, one of the first things it does, before executing any JavaScript code, is create a global object . The properties of this object are the globa...
2009-01-02 20:59:57
114
原创 No block scope
[size=medium]Note that unlike C, C++, and Java, JavaScript does not have lock-level scope. All variables declared in a function, no matter where they are declared, are defined throughout the function....
2009-01-02 14:11:43
116
原创 Variable Declaration
[size=medium]Variables declared with var are permanent : attempting to delete them with the delete operator causes an error. If you attempt to read the value of an undeclared variable, JavaScript ...
2009-01-02 12:53:19
479
原创 Primitive Types and Reference Types
[size=medium]Numbers and booleans are primitive types in JavaScriptprimitive because they consist of nothing more than a small, fixed number of bytes that are easily manipulated at the low levels of t...
2009-01-02 10:55:32
221
原创 Object Conversions
[size=medium]When a non-null object is used in a Boolean context, it converts to true . When an object is used in a string context, JavaScript calls the toString( ) method of the object and uses the ...
2009-01-01 19:09:11
161
原创 JavaScript boolean false
[size=medium]If a number is used where a boolean value is expected, the number is converted to TRue unless the number is 0 or NaN , which are converted to false . If a string is used where a boolean ...
2009-01-01 17:25:35
149
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅