DEV Community

Discussion on: What is the oddest JavaScript behavior?

Collapse
 
j_mplourde profile image
Jean-Michel Plourde • Edited

I find these very funny:

typeof(1 + '1') // returns a string because + is overloaded to concatenate

typeof(1 * '1') // but not *

"1" -- "1" // returns 2

"1" - "1" // returns 0