Converts a zero value to Boolean type in JavaScript

Description

The following code shows how to converts a zero value to Boolean type.

Example


<!--from w  w w.  j a  va 2  s .  co  m-->

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var anInt = 0;
var aBoolean = Boolean(anInt);
document.writeln(aBoolean);
</script>
</head>
<body>

</body>
</html>

Click to view the demo

The code above generates the following result.

Converts a zero value to Boolean type in JavaScript