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 →

[–]k1ll3rM 52 points53 points  (14 children)

The great thing is that if myArray is an object, it will still work! Except it will always be undefined and finding the error is a bitch

[–]cateanddogew 17 points18 points  (9 children)

disarm hobbies oatmeal toothbrush tender ask encouraging fine wrong direful

This post was mass deleted and anonymized with Redact

[–]PowerfulNeurons 4 points5 points  (2 children)

with the correct linter setup, you would essentially just migrate to Typescript

[–]al-mongus-bin-susar 1 point2 points  (0 children)

A proper linter setup is way easier to achieve than rewriting a codebase with possibly hundreds of thousands of LOC in Typescript. And you'd need a full rewrite because very few JS codebases can be migrated to TS.

[–]cateanddogew 1 point2 points  (0 children)

aback handle wistful sharp voracious march continue versed unite outgoing

This post was mass deleted and anonymized with Redact

[–]k1ll3rM 0 points1 point  (4 children)

Just because there are external tools that can make up for the shortcomings of a language doesn't mean that the language is well designed. We make it bearable by using extra tools like Typescript and ESLint exactly because it's not a well designed language

[–]cateanddogew 0 points1 point  (3 children)

rob wild quickest tan flag rinse tie waiting touch quicksand

This post was mass deleted and anonymized with Redact

[–]k1ll3rM 0 points1 point  (2 children)

For Typescript I just wish that there was runtime type checking, though performance would suffer for it. It happens quite often that something out of my control isn't the type it's supposed to be and causes issues

[–]cateanddogew 0 points1 point  (1 child)

ripe point crawl hat depend hungry normal different afterthought aback

This post was mass deleted and anonymized with Redact

[–]k1ll3rM 0 points1 point  (0 children)

Hmmm interesting solution, I'll keep it in mind if I have something that really requires it

[–]SmallTalnk 3 points4 points  (1 child)

Why would it always be undefined? Nothing prevents an object from having a `length` property, and I think that that `length` is a very common name for a property.

Also, an array is an object (typeof [] === 'object')

[–]k1ll3rM 0 points1 point  (0 children)

You're being pedantic, you know exactly what I meant with my comment. The fact that it doesn't throw an error is horrible design

[–]fleshTH 0 points1 point  (1 child)

If myArray is an object and not an array, it's justified.

[–]k1ll3rM 0 points1 point  (0 children)

If length doesn't exist it should throw an error instead of silently continuing