DekGenius.com
Team LiB   Previous Section   Next Section
Arguments.callee the function that is currently running

Availability

JavaScript 1.2; JScript 5.5; ECMAScript v1

Synopsis

arguments.callee

Description

arguments.callee refers to the function that is currently running. It provides a way for an unnamed function to refer to itself. This property is defined only within a function body.

Example

// An unnamed function literal uses the callee property to refer 
// to itself so that it can be recursive
var factorial = function(x) {
    if (x < 2) return 1;
    else return x * arguments.callee(x-1);
}
var y = factorial(5);  // Returns 120
    Team LiB   Previous Section   Next Section