Using arrays for everything will get you in the same place as using varchar columns for everything in an sql database: it might seem to save some effort and thinking in the short term, but it will be an enormous pain to maintain in the long run.
Passionate with code... In love with Web Design, Videogames, Books and Jazz music.Years of experience in "document composition" and a Front-End Developer wannabe (since years)
In the case of the DOM, you’re already working with objects, which just happen to be composed into larger hierarchies via arrays. Imagine if a DOM object were an array, where you’d have to look up each property in the array rather than having direct access to it. It’d be cumbersome to work with, not to mention the inherently poor performance that it would entail.
Passionate with code... In love with Web Design, Videogames, Books and Jazz music.Years of experience in "document composition" and a Front-End Developer wannabe (since years)
Yes, that allows you to leverage the extra methods (i.e. power) of javascript arrays (since a nodeList is just a poor-man’s array anyway). But that’s quite different from the approach you discuss above, about using arrays instead of objects with fields.
Passionate with code... In love with Web Design, Videogames, Books and Jazz music.Years of experience in "document composition" and a Front-End Developer wannabe (since years)
Using arrays for everything will get you in the same place as using varchar columns for everything in an sql database: it might seem to save some effort and thinking in the short term, but it will be an enormous pain to maintain in the long run.
Just someway to do It.
I agree that sometimes you’ve to work with It.
Consider the DOM... most of the times it’s easier to work with arrays.
In the case of the DOM, you’re already working with objects, which just happen to be composed into larger hierarchies via arrays. Imagine if a DOM object were an array, where you’d have to look up each property in the array rather than having direct access to it. It’d be cumbersome to work with, not to mention the inherently poor performance that it would entail.
Most of the time with nodeList... I know what you’re talking about but I use to convert them in arrays if there’s not a HUGE amount of stuff to do.
Yes, that allows you to leverage the extra methods (i.e. power) of javascript arrays (since a nodeList is just a poor-man’s array anyway). But that’s quite different from the approach you discuss above, about using arrays instead of objects with fields.
Maybe It was not so clear ☹️