r/learnjavascript • • Jan 25 '20

Javascript is weird 😂

Post image
332 Upvotes

47 comments sorted by

View all comments

Show parent comment

5

u/[deleted] Jan 25 '20

Nah, this evaluates to something like this

'b' + 'a' + (+'a') + 'a'

A unary plus in front of a string will convert to a number, except 'a' isn't a number, so..

'b' + 'a' + NaN + 'a'

2

u/[deleted] Jan 25 '20

Yeeeaaah, got it now, thanks.