DEV Community

Discussion on: Changelog: Stack Overflow Liquid Tag

Collapse
 
pixmy profile image
Arturo Cabrera

"Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?"

hahahahaha I'm dying

Collapse
 
ben profile image
Ben Halpern

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

console.log(+'a')
To lowercase it becomes banana.

Adding NaN to "ba" turns NaN into the string "NaN" due to type…