- 博客(31)
- 收藏
- 关注
原创 Extending Built-in Types
The Function.apply( ) method is missing in Microsoft Internet Explorer 4 and 5. This is a prettyimportant function, and you may see code like this to replace it: // IE 4 & 5 don't implement F...
2009-01-08 13:55:44
175
原创 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
117
原创 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
130
原创 Constructor Functions
the new operatorcreates a new object and then invokes the constructor function, passing the newly created object as thevalue of the this keyword.
2009-01-07 00:42:43
213
原创 Functions as Methods
When a function is invoked as a function rather that as a method, the this keyword refers to the globalobject. Confusingly, this is true even when a nested function is invoked (as a function) within ...
2009-01-07 00:39:40
152
原创 The callee Property
In addition to its array elements, the Arguments object defines a callee property that refers to thefunction that is currently being executed. This property is rarely useful, but it can be used to al...
2009-01-07 00:02:42
121
原创 Variable-Length Argument Lists: The Arguments Obje
The Arguments object has one very unusual feature. When a function has named arguments, the arrayelements of the Arguments object are synonyms for the local variables that hold the function arguments...
2009-01-06 23:06:39
126
原创 Function Literals
Although function literals create unnamed functions, the syntax allows a function name to be optionallyspecified, which is useful when writing recursive functions that call themselves. For example:...
2009-01-06 21:50:51
150
原创 Nested Functions
Nested functions may be defined only at the top level of the function within which they are nested. Thatis, they may not be defined within statement blocks, such as the body of an if statement or whi...
2009-01-06 21:09:11
213
原创 Deleting Array Elements
The delete operator sets an array element to the undefined value, but the element itself continues toexist. To actually delete an element, so that all elements above it are shifted down to lower inde...
2009-01-05 22:11:51
161
原创 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 anumber that is too large, a negative number, or a floating-point number (or a boolean, an object...
2009-01-05 22:00:44
117
原创 The valueOf() Method
[size=medium] JavaScript calls thismethod automatically if an object is used in a context where a primitive value is ...
2009-01-05 18:05:38
145
原创 The toLocaleString() Method
[size=medium]In ECMAScript v3 and JavaScript 1.5, the Object class defines a toLocaleString() method in addition toits toString() method. The purpose of this method is to return a localized string r...
2009-01-05 18:02:34
226
原创 The constructor Property
[size=medium]Since constructor functions define new categories or classes of objects, the constructor property can helpdetermine the type of an object. For example, you might use code like the follo...
2009-01-05 17:51:51
129
原创 the empty statement
[size=medium]When you intentionally use the empty statement, it is a good idea to comment your code in a way thatmakes it clear that you are doing it on purpose. For example:[code="javascript"]for...
2009-01-05 00:29:39
151
原创 with
[size=medium]The with statement is used to temporarily modify the scopechain. It has the following syntax:[code="javascript"]with (object) statement[/code]This statement effectively adds ob...
2009-01-05 00:27:26
104
原创 try/catch/finnaly
[size=medium]If control leaves the try block because of a return , continue , orbreak statement, the finally block is executed before control transfers to its new destination.If a finally bloc...
2009-01-05 00:17:54
160
原创 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 instanceof one of the su...
2009-01-04 23:56:59
103
原创 return
[size=medium]If a function executes a return statement with no expression , or if it returns because it reaches the endof the function body, the value of the function-call expression is undefined ....
2009-01-04 23:52:37
138
原创 functions
[size=medium]Technically speaking, the function statement is not a statement. Statements cause dynamic behavior in aJavaScript program, while function definitions describe the static structure of a ...
2009-01-04 23:48:51
93
原创 Labels
[size=medium]Label names aredistinct from variable and function names, so you do not need to worry about name collisions if you give alabel the same name as a variable or function.When break i...
2009-01-04 23:01:58
138
原创 for/in loop
[size=medium]JavaScript arrays are simply a specialized kind of object. Therefore, the for/in loop enumerates arrayindexes as well as object properties.The for/in loop does not specify the order...
2009-01-04 22:53:05
165
原创 switch
[size=medium]The switch statement first evaluates the expression that follows the switch keyword and then evaluatesthe case expressions, in the order in which they appear, until it finds a value tha...
2009-01-04 20:39:59
110
原创 Local Variables: The Call Object
[size=medium]If global variables are properties of the special global object, then what are local variables? They too areproperties of an object. This object is known as the call object . The call...
2009-01-02 23:33:23
120
原创 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
95
原创 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
102
原创 Variable Declaration
[size=medium]Variables declared with var are permanent : attempting to delete them with the delete operator causesan error.If you attempt to read the value of an undeclared variable, JavaScript ...
2009-01-02 12:53:19
448
原创 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
199
原创 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 astring context, JavaScript calls the toString( ) method of the object and uses the ...
2009-01-01 19:09:11
131
原创 JavaScript boolean false
[size=medium]If a number is used where a boolean value is expected, the number is converted to TRue unless thenumber is 0 or NaN , which are converted to false . If a string is used where a boolean ...
2009-01-01 17:25:35
134
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人