Created
August 2, 2019 08:53
-
-
Save Neophen/6e41d43870a7221d690ff6cecc1e440c to your computer and use it in GitHub Desktop.
String coercion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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