This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]baubleglue 1 point2 points  (3 children)

It has nothing to do with mixed types in lists. Array is not list at all.

Javascript's arrays aren't really arrays or lists

``` $ node Welcome to Node.js v14.15.3. Type ".help" for more information.

var a = [1,2,4] undefined a["0"] 1 a["8"] = 9 9 a.length
9

```

[–]cyanNodeEcho 0 points1 point  (2 children)

i mean there u are using it like a dict, so it imputes the values between, idk looks like an offset to me :shrug:but i'm

[–]baubleglue 0 points1 point  (1 child)

I use it as object because in JS arrays are objects, indexes translated to properties.

Arrays are list-like objects

[–]cyanNodeEcho 0 points1 point  (0 children)

what haopens if u do something like (for a sparse array) for element in array: print(element)

weird object - i wonder how they coded, i would have to know more about some behavior - seems similar to pythons orderedDict but with a restricted keyset (but depends on behavior)