Why are Javascript function arguments not stored in a normal array? -
i need join arguments passed function , return them string , remember reading somewhere javascript used special type of array store arguments inside. when tried call arguments.join("")
got runtime error telling me there no such method.
why doesn't javascript store arguments in standard array using references point argument names?
well 1 of ways in arguments
special does, in fact, refer parameters directly. not possible in javascript regular array instance.
function foo( param ) { arguments[0] = "changed"; alert( param ); // says "changed" } foo( "original" );
now whether that's "feature" or not debatable question; can't recall using purpose other create irritating bugs. point having plain array instance somehow have rather bizarre behavior (bizarre in javascript terms) open sorts of weird issues.
edit — it's pointed out in comment 1 make array instance setters , getters mimic behavior. it'd sort-of hard programatically in one's own code (in general way, , not on ad-hoc basis, mean), runtime it.
Comments
Post a Comment