Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Function() > The arguments.callee Property

The arguments.callee Property

The arguments object has a property called callee, which is a reference to the function currently executing. This property can be used to reference the function from within the scope of the function (e.g., arguments.callee)—a self-reference. In the code below, we use this property to gain a reference to the calling function.

Live Code

<!DOCTYPE html><html lang="en"><body><script>

var foo = function foo() {
   console.log(arguments.callee); // logs foo()
   /* callee could be used to invoke recursively the foo function 
   (e.g., arguments.callee()) */
}();

</script></body></html>

This can be useful when a function needs to be called recursively.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint