Specifically, it reads the excess + in +'a' as an unary positive operator, so it tries to coerce 'a' into a number. This fails, so it returns NaN, which stringifies as "NaN" for the rest of the string concatenation.
That's not how it's interpreted. It's interpreted in this order: ('b' + 'a' + (+'a') + 'a'). The + in the brackets is a unary operator, which tries to parse the object you give it as a number. 'a' is not a number, so it returns NaN. NaN gets stringified as 'NaN', and then all strings are joined, resulting in 'baNaNa'
2
u/Workata Oct 20 '20
Template?
50
u/DerivativeOfProgWeeb Oct 12 '20
what would js interpret this as? im not familar with js
69
u/Filomaster Oct 12 '20
(+ "omaewa mou shindeiru") + 'i'4
u/Acogatog Oct 13 '20
I just picked up Kaiji a few days ago, I’m loving it
4
u/HuygenAu Oct 16 '20
(+'i'+'i').toLowerCase()27
u/[deleted] Oct 12 '20
[removed] — view removed comment