Marcus Young

Software. Microcontrollers. Beer.

JavaScript Likes to Play Dumb

| Comments

My first post is going to be some fun coersion issues I have found lately while touching up on my JavaScript

 == ''   // returns true
 == '0' //returns true (odd since false == 'false' returns false)

…And…

' ' ==  // returns true

Also my favorite (thanks to destroyallsoftware)

Array(5).join('wat'+1)//returns wat1wat1wat1wat1wat1
Array(5).join('wat'-1)//returns NaNNaNNaNNaNNaN

Comments