Computer >> Computer tutorials >  >> Programming >> Javascript

What will happen when 1 is converted to Boolean in JavaScript?


You can try to run the following code to learn how to convert 1 to Boolean in JavaScript −

Example

<!DOCTYPE html>
<html>
   <body>
      <p>Convert 1 to Boolean</p>
      <script>
         var myVal = 1;
         document.write("Boolean: " + Boolean(myVal));
      </script>
   </body>
</html>