Created
October 18, 2019 12:17
-
-
Save CodersArts/8fd4b22977c686c7550d53b5485f1c55 to your computer and use it in GitHub Desktop.
Boolean can be objects
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
#Codersarts | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<p>Never create booleans as objects.</p> | |
<p>Booleans and objects cannot be safely compared.</p> | |
<p id="demo"></p> | |
<script> | |
var x = false; // x is a boolean | |
var y = new Boolean(false); // y is an object | |
document.getElementById("demo").innerHTML = typeof x + "<br>" + typeof y; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment