The function Object [3]

The function object provides a mechanism for indicating JavaScript code to compile as a function. This is the syntax to use the function object:

functionName = new Function(arg1, arg2, arg3, ..., functionCode)

This is similar to the following:

function functionName(arg1, arg2, arg3, ...) {
   functionCode
}

In the former, functionName is a variable with a reference to the function, and the function is evaluated each time it's used instead of being compiled once.

Properties

  • arguments— An integer reflecting the number of arguments in a function.

  • prototype— Provides a mechanism for adding properties to a function object.

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.