December 2001
Intermediate to advanced
480 pages
9h 22m
English
As illustrated in the previous section, functions can be treated as data. Like any other data, functions express some type of value, whether it be string, numeric, or Boolean. This next section considers two more methods of creating functions. The first method uses the Function() constructor, and the second uses function literals.
The Function() constructor looks like the new object or array constructor. It has this general format:
var variableName=new Function("exp1", "exp2", "return exp3;"); Here, exp1 is a necessary first expression, exp2 is an optional second expression, and exp3 is an expression made up of exp1 and exp2. For example, the following script uses item as exp1 and ...
Read now
Unlock full access