If a value is false, undefined, null, NaN, 0, -0, or an empty string(""), it is false! but any other value in JavaScript will be converted to true if used in a Boolean context.
<!DOCTYPE html>
<html lang="en">
<body>
<script>
var myBoolean = new Boolean(false);
console.log( myBoolean );
console.log( myBoolean.toString() );
console.log( myBoolean.valueOf() );
if( myBoolean )
console.log( typeof myBoolean );
</script>
</body>
</html>
No comments:
Post a Comment