Live data from Hacker News

Stranger Things, JavaScript Edition

livecodestream.dev

11–20 of 58 posts

Re: Stranger Things, JavaScript Edition

#14
post #12

Common confusion has to do with how JS overloads the "+" operator. '9' + 1 = "91" +'9' + 1 = 10 It's all very weird though...

What would you expect string + number to do?

Incompatible types error, either at runtime or during compilation depending on the language

Re: Stranger Things, JavaScript Edition

#16
" ['1', '7', '11'].map(parseInt);

For what you would expect the output to be:

[1, 7, 11]

However, things get a bit off here, and the actual result is:

[1,NaN,3]

At first, this may look up very weird, but it actually has an elegant explanation. "

The elegant explanation is that JavaScript was taken over by psychopaths like bajcmartinez.

JavaScript is fine for button onClick code. Outside of that it's garbage.

Re: Stranger Things, JavaScript Edition

#20
post #12

Common confusion has to do with how JS overloads the "+" operator. '9' + 1 = "91" +'9' + 1 = 10 It's all very weird though...

Meh, prefix + converts a string into an integer, so it'd be something like toInteger('9') + 1. I agree prefix + is weird, but nothing mind-blowing.
Post reply on HN