JavaScript_Succinctly
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Sample: sample84.html<br />
<br />
var foo = function foo() {<br />
console.log(arguments.callee); // Logs foo()<br />
// callee could be used to invoke recursively the foo function (e.g.,<br />
arguments.callee())<br />
} ();<br />
<br />
This can be useful when a function needs to be called recursively.<br />
The function instance length property and arguments.length<br />
The arguments object has a unique length property. While you might think this length<br />
property will give you the number of defined arguments, it actually gives the number of<br />
parameters sent to the function during invocation.<br />
Sample: sample85.html<br />
<br />
var myFunction = function (z, s, d) {<br />
return arguments.length;<br />
};<br />
console.log(myFunction()); // Logs 0 because no parameters were passed to<br />
the function.<br />
<br />
Using the length property of all Function() instances, we can actually grab the total<br />
number of parameters the function is expecting.<br />
Sample: sample86.html<br />
<br />
var myFunction = function (z, s, d, e, r, m, q) {<br />
return myFunction.length;<br />
};<br />
console.log(myFunction()); // Logs 7.<br />
<br />
95