Javascript is strange: ('b'+'a'+ +'a'+'a').toLowerCase() == 'banana'

in blog •  3 days ago 

('b'+'a'+ +'a'+'a').toLowerCase() == 'banana'

('b'+'a'+ +'a'+'a').toLowerCase()
'banana'

Why?

+ + 'a' is + (+ 'a') which becomes NaN

So

('b'+'a'+ +'a'+'a')
is
'baNaNa'

And then converted to Lowercase:

'banana'

image.png

The Weird Thing about Javascript – Part I

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

wow~ Interesting results! :)