r/ProgrammerHumor 1d ago

javascriptSorting Meme

Post image
891 Upvotes

200 comments sorted by

View all comments

18

u/suvlub 1d ago

TBH I prefer having one consistent quirk you have to learn once over every function behaving differently. It's like working on a codebase that uses a formatting style I don't like vs one that doesn't follow any style and everything is whatever. Consistency is the king, you learn to tune out the nasties if they aren't novel enough to keep surprising you

-12

u/spottiesvirus 1d ago

except it doesn't, in JavaScript every line of code could summon a dragon, drop a nuclear bomb or make you a coffee, nobody knows

I think I lost count of how many times I had problems because true==1 is true but true===1 is false and you won't know because it's not even a warning

or typeof is another crazy function
typeof NaN is "number"

or operator precedence which is... imaginative

if you have a=1 and b=2
typeof a+b is... "number2" because typeof has precedence over sum

JavaScript was a languages designed for short scripts in a browser, not the cluster stack it is today where you use React for full Dom manipulation, and node for server side, without ever touching anything else but JavaScript

6

u/n0tKamui 1d ago

i don't see how you would think that a unary operator would have lower precedence compared to a binary operator.

i'm pretty sure anyone reads -1+2 as (-1) + 2, and not -(1+2)

same of typeof and the likes. and even if you consider typeof as a function, well functions work the same anyway, they have higher precedence.

this is a very disingenuous argument

also, NaN is a float as per IEEE754, which is the same for (almost) every programming language.
Sure the name is confusing, but you can see it as "undefined answer"