Var statement using the definition of variables. When the variables in the function of the internal definition, var scope of a function (function-scope) level, this variable should not be accessed outside the function. JavaScript is not the scope of other domain size, and more specifically, JavaScript is not the domain block (block-scope).
The use of any function but no clear definition of the variable var will be assumed to belong to the overall object.
Was clearly not initialize any variable will be assigned to the undefined.
2, function return value
javaScript no void type, so every function must return a value, in addition to outside Constructor The default value is undefined, the default constructor return value is this
3, if judged
In the if statement, while statements, do statements, and logical operators in, JavaScript as false, null, undefined, "" (empty string), and the number 0 as false (false). All other values were regarded as true (true).
4, logic to determine
& & Operator, generally referred to as "logical and" (logical and), it is also known as the guard, if the first operand is false, null, undefined, "" (empty string) or 0 then the figure will be the first return an operand, or they will return the second operand. This provides a convenient method of testing null values:
var value = p & & p.name; / * The name value will
only be retrieved from p if p has a value, avoiding an error. * /
| | Operators are generally known as "logical or" (logical or), it is also known as the default, if the first operand is false, null, undefined, "" (empty string) or the number 0, it will return The second operand, otherwise return the first operand. This provides a convenient way of setting default values:
value = v | | 10; / * Use the value of v, but if v
doesn't have a value, use 10 instead. * /







