samedi 29 novembre 2014

nodejs `arguments` is object but in the browser, it is an `array`


When I access arguments from inside called function in nodejs...



echo '!function(){ console.log(arguments) }(1,2,3)' | node


... it outputs an object ...



{ '0': 1, '1': 2, '2': 3 }


... but in google chrome ...



!function(){ console.log(arguments) }(1,2,3)


... outputs ...



[1, 2, 3]


Why is it not consistent? What other js environments have this different behaviour? Is it ok for me to use arguments? How can I ensure it is always an array before I use it?





Aucun commentaire:

Enregistrer un commentaire