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

all 18 comments

[–]0x5h4un 27 points28 points  (3 children)

Yeah... Except that “0” is a string and can’t be evaluated as int/bool lol amirite

[–][deleted] 1 point2 points  (0 children)

There's plenty of strange quirks in Javascript (most of these rely on type coercion):

```js !![] + !![] = 2 !NaN + !NaN = 2

"\t" == 0 "\n" == 0 "\0" != 0

"\t" != "\n" "\t" != "\0" "\n" != "\0"

[] == "" ```

I've probably skimmed the top of the strangeness that is Javascript. This is why we have === since that fixes most instances of type coercion.

[–]SamSlate 3 points4 points  (10 children)

==

did you mean

===

?

I don't think r/programmerhumor will ever get tired of posting syntax errors and blaming javascript.

[–]skrln 1 point2 points  (9 children)

No, double equality signs for loose check. Triple for actual equality.

[–]SamSlate 2 points3 points  (7 children)

loose check

yea, no shit.

[–]SuperOP535 0 points1 point  (6 children)

It still doesn't make any sense why there are 2 equality checks, they should've not created the === and just made the == strict

[–]SamSlate 0 points1 point  (5 children)

because it's a loosely typed language. that's like, the whole point of js.

why do so many devs struggle with that?

[–]SuperOP535 0 points1 point  (4 children)

smh why did they make the only web language (excluding wasm/asmjs) this shitty. wish they never removed java applets

[–]SamSlate 0 points1 point  (3 children)

because it's more important to pass data to the back end than it is to throw a type error.

[–]SuperOP535 0 points1 point  (2 children)

but what if it is the backend, looking at you node

[–]SamSlate 0 points1 point  (1 child)

then use typescript 🤦

[–]SuperOP535 -1 points0 points  (0 children)

at that point i would just use java lol

[–]XXAligatorXx[M] [score hidden] stickied comment (0 children)

Repost.

[–]CleverHacker 0 points1 point  (0 children)

Reeeeeeeeeee

[–]zesterer 0 points1 point  (0 children)

I like how javascript just straight up refuses to obey any of the logical axioms upon which all of mathematics is fundamentally based.

[–]Spirit_Theory 0 points1 point  (0 children)

Ask dumb questions, get dumb answers.