文章列表
[size=medium]The with statement is used to temporarily modify the scope
chain. It has the following syntax:
with (object)
statement
This statement effectively adds object to the front of the scope chain, executes statement , and then
restores the scope chain to its original state.
Despite its o ...
- 2009-01-05 00:27
- 浏览 683
- 评论(0)
try/catch/finnaly
- 博客分类:
- JavaScript
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 block itself transfers control with a return , continue , break , or throw statement, or by
calling a method that throws a ...
- 2009-01-05 00:17
- 浏览 890
- 评论(0)
throw
- 博客分类:
- JavaScript
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 subclasses of Error. It can also be useful to throw a string that contains an error message,
or a numeric value that re ...
- 2009-01-04 23:56
- 浏览 691
- 评论(0)
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 .
Because of JavaScript's automatic semicolon insertion, you may not include a line break between the
return keyword ...
- 2009-01-04 23:52
- 浏览 815
- 评论(0)
[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 program. Statements are
executed at runtime, but functions are defined when JavaScript code is parsed, ...
- 2009-01-04 23:48
- 浏览 789
- 评论(0)
Labels
- 博客分类:
- JavaScript
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 is used with a label, it jumps to the end of, or terminates, the named statement, which may
be any enclosing statement. ...
- 2009-01-04 23:01
- 浏览 706
- 评论(0)
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 in which the properties of an object are assigned to the
variable. There is no way to tell what the order will be in ...
- 2009-01-04 22:53
- 浏览 1320
- 评论(0)
switch
- 博客分类:
- JavaScript
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 that matches. The
matching case is determined using the === identity operator, not the == equality operator, so the
ex ...
- 2009-01-04 20:39
- 浏览 631
- 评论(0)
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 object has a shorter lifespan than
the global object, but it serves the same purpose. While the body of a function ...
- 2009-01-02 23:33
- 浏览 668
- 评论(0)
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 global variables of JavaScript programs. When you declare a global JavaScript variable, what you are actually doing is d ...
- 2009-01-02 20:59
- 浏览 665
- 评论(0)
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.
it is good programming practice to place all your variable declarations together at the start of any function.
- 2009-01-02 14:11
- 浏览 688
- 评论(0)
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 generates an error. If you assign a
value to a variable that you have not declared with var , JavaScript implicitly d ...
- 2009-01-02 12:53
- 浏览 1115
- 评论(0)
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 the JavaScript interpreter. Objects, on the other hand, are
reference types. Arrays and functions, which are specia ...
- 2009-01-02 10:55
- 浏览 915
- 评论(0)
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 string value returned
by that method. When an object is used in a numeric context, JavaScript first calls the value ...
- 2009-01-01 19:09
- 浏览 641
- 评论(0)
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 value is expected,
it is converted to true except for the empty string, which is converted to false . null and the ...
- 2009-01-01 17:25
- 浏览 822
- 评论(0)