That is just the kind of Stack content I hope this feature will help bump π
The answer is pretty great
+'a' resolves to NaN ("Not a Number") because it coerces a string to a number, while the character a cannot be parsed as a number
+'a'
NaN
a
console.log(+'a')
banana
Adding NaN to "ba" turns NaN into the string "NaN" due to typeβ¦
"ba"
"NaN"
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That is just the kind of Stack content I hope this feature will help bump π
The answer is pretty great
answer re: Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?
+'a'
resolves toNaN
("Not a Number") because it coerces a string to a number, while the charactera
cannot be parsed as a numberbanana
.Adding
NaN
to"ba"
turnsNaN
into the string"NaN"
due to typeβ¦