While reverse-engineering some obfuscated JavaScript code for a CTF, I came across the following syntax:
array['push']('5');
It pushes '5' at the end of the array, which seems logical, but I just do not understand why this syntax works, since I haven't managed to find anything about it (not on the Mozilla Developer Network, not on the W3C website, and the latest ECMAScript specification is a bit too dense for me to understand).
I'm thinking it has something to do with arrays being a special case of objects, but I'm not versed enough in JavaScript to figure it out.
array['push']means exactly the same thing asarray.push. It has nothing to do with arrays being special. That's the normal and universal way that object property access works in JavaScript.