Re:Fun with JavaScript Arrays
by jdlshore on Wednesday June 12, 2013 @10:21AM
(#5868195)
Technically, the special API is because arrays extend Array.prototype. You could create an object that does the same, and push(), pop(), etc would work.*
Try going to http://www.objectplayground.com and putting in the following code, selecting the "Show built-in objects" option, and evaluating:
*Well, they sort of work. They use and modify the "length" property, so you could see some weird behavior under some circumstances. Not recommended for production use. :-)
Try going to http://www.objectplayground.com and putting in the following code, selecting the "Show built-in objects" option, and evaluating:
*Well, they sort of work. They use and modify the "length" property, so you could see some weird behavior under some circumstances. Not recommended for production use. :-)