Resin 1.1
FAQ
Reference
JavaDoc
Demo
Java Tutorial
Getting Started
Configuration
Servlet
JSP
XTP/XSL
JavaScript
JS Library
Core Library
File Library
Servlet Library
Database Library
XML Library
Global
Object
Array
Boolean
Date
Function
Math
Number
Regexp
String
The Function Object
Function Constructor
Function([arg1, arg2, ..., argn], body) | Creates an anonymous function.
new Function([arg1, arg2, ..., argn], body) | Equivalent to `new Function`
Function Instance Properties
| Returns the function's expected number of arguments.
Function Instance Methods
| Calls the function using obj as the function's `this`.
apply(this [, args]) | Applies the function to the argument array.
Function Constructor
### Function([arg1, arg2, ..., argn], body)
Creates an anonymous function. The function call is roughly equivalent to
function (arg1, arg2, ..., argn) { body }
The primary difference is that the `Function` call does not create a closure, i.e. the scope of the anonymous function is the global scope.
Function call
var a = 1; function foo(a) { return Function("z", "return z + ',' + a"); } writeln(foo(2)(1));
1,1
function closure
var a = 1; function foo(a) { return function(z) { return z + ',' + a } } writeln(foo(2)(1));
1,2
### new Function([arg1, arg2, ..., argn], body)
Equivalent to `new Function`
Function Instance Properties
### length
Returns the function's expected number of arguments.
Function Instance Methods
### call(obj [, arg1, ..., argn]) | ### JavaScript 1.3
Calls the function using obj as the function's `this`. Rougly equivelent to:
obj.fun = fun; obj.fun(arg1, ..., argn);
function add(b) { return this.a + ',' + b; } add.call({a:1}, 7)
1,7
### apply(this [, args]) | ### JavaScript 1.3
Applies the function to the argument array.
function add() { return this.a + ' ' + arguments.join(); } add.apply({a:"foo"}, [3, 2, 1]);
foo 3,2,1
Date |  | Math
Copyright © 1998-2000 Caucho Technology. All rights reserved. Last modified: Fri, 31 Mar 2000 18:51:27 -0800 (PST)