Skip to content

Instantly share code, notes, and snippets.

@Neophen
Created August 2, 2019 08:53
Show Gist options
  • Save Neophen/6e41d43870a7221d690ff6cecc1e440c to your computer and use it in GitHub Desktop.
Save Neophen/6e41d43870a7221d690ff6cecc1e440c to your computer and use it in GitHub Desktop.
String coercion
let value;
value = String( -0 );
console.log(value); // "0" OOPS!
value = String( null );
console.log(value); // "null"
value = String( undefined );
console.log(value); // "undefined"
value = String( [] );
console.log(value); // "" OOPS!
value = String( [null] );
console.log(value); // "" OOPS!
value = String( [undefined] );
console.log(value); // "" OOPS!
// and last but not least :D
Boolean( new Boolean(false) ); // true OOPS!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment