Hacker News new | past | comments | ask | show | jobs | submit login
NodeLists and Arrays in JavaScript (duruk.net)
18 points by franze on June 22, 2011 | hide | past | favorite | 3 comments



Careful readers of the W3C definition will note that arrays in most languages, like JavaScript, are almost what this definition implies NodeLists are: “ordered collection of (things)”

What? I think of arrays as contiguous blocks of memory - to me that's their defining feature. Is that incorrect?


W3C is not the programming standard body (is there a such a thing?)

But yes, Array in lower(?) level language is suppose to be defined as a contiguous block of memory (C). In more higher level languages what people think are arrays '[ ]' are usually lists (e.g. python)


It isn't correct in JS. Arrays aren't aren't guaranteed to be dense, and even if they are, the nature of JS means that they're usually holding references. (Compared to say, a contiguous block of some multiple of sizeof(<some struct>) bytes.)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: