Home » Posts tagged "boolean"

JavaScript Boolean Confusion

What could possibly be confusing about JavaScript Booleans you ask?

Well, here’s several logical statements written in JavaScript.  Do you know what each does?

 

 

if("0" == true)

if("0")

if("1" === true)

if(!!"0" == true)

if("0" != true)

if("0" !== true)

var someVariable;
if(someVariable)

if(someVariable == true)

if(!someVariable === true)

if(!!someVariable === true)

Continue reading “JavaScript Boolean Confusion”