argumentsspecial variable available in the scope of a function. It contains all the arguments passed to a function. For example,
function p() { ... } function q(x) { ... } p(1,2,3,4); // arguments.length = 4 q(1,2,3,4); // arguments.length = 4. // Ie, the first argument is not swallowed by x.
Function.prototype.call(t[, args]*). Calls the function passing alongargsin a content wherethisrefers tot.
Function.prototype.apply(t, arg). Same ascallexcept the argument is an array. Coming from R, I had thought this meant the function was applied to each element ofarg.
Array.prototype.map(f). Applies functionfto each element of the array, returning a new array.
Array.prototype.forEach(f). Applies functionfto each element of the array but returnsundefined. In other words, basically used only for side effects such as printing to screen, writing to filesystem, etc.
Be aware that
1 + "5"; // "15"
"1" + 5; // "15"
"5" & 20; // 0
"5" & 21; // 5
"1" & "a"; // 0 (Octal of ASCII "1" is 061)
"1" & "b"; // 0
var x = { 1:"b", "5":"e" };
x["1"] == x[1]; // TRUE
x[5] == x["5"]; // TRUE
No comments:
Post a Comment