JavaScript
undefined
. //Copy property names to a. //If a is missing, create a new a. function copyPropertyNamesToArray(o, /*optional*/ a){ if (!a) { a = []; }; for (var p in o) { a.push(p); } return a; }
arguments
refers to the
arguments array and callee
is a property of
it.callee
refers to the function that is
currently being executed, used in recursive lambda functions
function getArguments(){ //can't use join() because arguments is an object (that looks like an array). var result = ""; for (var i =0; i< arguments.length; i++){ result += arguments[i] + " "; } return result; } function getCaller(){ return arguments.callee; }getArguments(1,2,3)
f = function(x) { if (x <= 1){ return 1; } return x * arguments.callee(x-1); }
40 of 65