Skip to content

Instantly share code, notes, and snippets.

@CodersArts
Created October 18, 2019 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodersArts/8fd4b22977c686c7550d53b5485f1c55 to your computer and use it in GitHub Desktop.
Save CodersArts/8fd4b22977c686c7550d53b5485f1c55 to your computer and use it in GitHub Desktop.
Boolean can be objects
#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