Monthly Archives: September 2014

Javascript: The Bad Parts

Did you know:

var test = parseInt( 'hello', 10 ); // returns NaN
if ( test === NaN ) {
  alert( 'Well that made sense' );
} else if ( 'number' !== typeof test ) { // Should work, right? NaN means NOT A NUMBER
  alert( 'Should not have to come to this, but still makes sense' );
} else {
  alert( 'WAT' ); // Should have used isNaN()
}

ಠ_ಠ

Reminded me of this: