607
you are viewing a single comment's thread
view the rest of the comments
[-] axsyse 4 points 1 year ago

Identity. "A is literally B" instead of "A equals B". This is necessary here in JS because if A is the string "-1" and B is the integer -1, JS evaluates A==B as true because reasons

[-] ForbiddenRoot@lemmy.ml 2 points 1 year ago* (last edited 1 year ago)

because if A is the string “-1” and B is the integer -1, JS evaluates A==B as true because reasons

Interesting. If it were the other way around, I think I would have been fine with it (i.e. == used for comparison with type like any other language and === without type). But as it stands now I would hate it if I had to write in JS (but I don't so it's fine).

[-] rikudou@lemmings.world 3 points 1 year ago

It's not that bad, honestly, just something you get used to. When I switch to C++ after a while, I sometimes write === and when I switch back to JS after some time, I occasionally forget to use ===.

In C++ it's obviously an error and for JS I have my IDE set to warn me about ==. I think I've used == in JS (and PHP) intentionally once in the last ~5 years.

[-] axsyse 1 points 1 year ago

Honestly, I think it actually makes some sense this way around. To me, in JS "==" is kinda "is like" while "===" is "is exactly". Or, put another way, "equals" versus idk, "more-equals". I mean, "===" is a much stronger check of equivalence than normal "==", so I think it deserves to be the one with the extra "="

this post was submitted on 14 Aug 2023
607 points (92.6% liked)

Programmer Humor

32584 readers
1101 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS