Name
Arguments.callee — the function that is currently running
Availability
not defined in strict mode
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
Get JavaScript: The Definitive Guide, 6th Edition 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.