
12
|
JavaScript Pocket Reference
typeof
Return the type of the operand as a string. Evaluates to
“number”, “string”, “boolean”, “object”, “function”, or
“undefined”. Evaluates to “object” if the operand is
null.
instanceof
Evaluates to true if the object on the left was created
with the constructor function (such as
Date or RegExp)on
the right.
in
Evaluates to true if the object on the right has (or inher-
its) a property with the name on the left.
delete
Deletes an object property. Note that this is not the same
as simply setting the property to
null. Evaluates to false
if the property could not be deleted, or true otherwise.
void
Ignores the operand and evaluates to undefined.
Statements
A JavaScript program is a sequence of JavaScript statements.
Most JavaScript statements have the same syntax as the cor-
responding C, C++, and Java statements.
Expression statements
Every JavaScript expression can stand alone as a statement.
Assignments, method calls, increments, and decrements are
expression statements. For example:
s = "hello world";
x = Math.sqrt(4);
x++;
Compound statements
When a sequence of JavaScript statements is enclosed within
curly braces, it counts as a single compound statement. For