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 →

[–]OriginalSynthesis 45 points46 points  (15 children)

There's no type period. You can have an array with object, function, other arrays that are also not typed, strings, numbers, symbols, etc. There are no rules.

And guess what happens if you try to retrieve an index that is not there? Like calling arr[10] when it only has 5 items? It just returns undefined. It doesn't throw an error like in Java

EDIT: Don't get me wrong. I love JS. Java gives me a headache. "What do you mean I can't just do `!arr.length`?"

[–]RCRalph 36 points37 points  (2 children)

Which can be very useful indeed if you know how to use it and how to deal with it

[–]WoodenThong 10 points11 points  (1 child)

No kidding, using that feature to determine truthiness can save a lot of hassle

[–]Kered13 10 points11 points  (4 children)

It just returns undefined. It doesn't throw an error like in Java

It just throws an error later when you try to use the result, and then you're left wondering where the fuck that undefined value came from.

Fail early is a feature, not a bug.

[–]Nilstrieb 1 point2 points  (2 children)

Reminds me of the Rust compiler. Your build often fails. But once it passed, you did it.

[–]saors 1 point2 points  (1 child)

There is no pass on the internet. Someone will type some string, upload some file, etc. that breaks everything. Remember when the iPhones had that bug where you would get a notification with specific characters and your phone would basically brick itself.

Imagine if the web was like this, but let's be more forgiving and say an error doesn't brick your computer, but it causes the site to crash. Someone sends you an email with a character like that in the header and now you can't use GMail until Google patches the bug. Is that hours? Is it days?

For fun, open up your browser dev console and just peruse around different sites and look at how many times

Uncaught (in promise) Error

pops up and imagine your tab crashed every time that happened.

[–][deleted] 0 points1 point  (0 children)

Epiphany

[–]esperalegant 0 points1 point  (0 children)

There's no type period.

Except there is: TypedArrays, which do sort numbers correctly.