How are javascript arrays implemented?
问题 Namely, how does the following code: var sup = new Array(5); sup[0] = 'z3ero'; sup[1] = 'o3ne'; sup[4] = 'f3our'; document.write(sup.length + "<br />"); output '5' for the length, when all you've done is set various elements? My 'problem' with this code is that I don't understand how length changes without calling a getLength() or a setLength() method. When I do any of the following: a.length a['length'] a.length = 4 a['length'] = 5 on a non-array object, it behaves like a dict / associative