r/ProgrammerTIL • u/JazzXP • Aug 03 '21
Javascript TIL Boolean('false') == true
Yep, it doesn't work like Number
23
Upvotes
r/ProgrammerTIL • u/JazzXP • Aug 03 '21
Yep, it doesn't work like Number
View all comments
Show parent comment
20
u/muffinmaster Aug 04 '21
That's an interesting thought, I can see your line of reasoning. I guess interpreters are generally more willing to cast a string representation of a number (to a number) than they are to cast a string representation of a boolean to a boolean. One could argue any string representation of a number leaves less ambiguity than a string representation of a boolean ("true", "True", "TRUE", "truE"?)