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

Live Demo

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

Updated on: 23-Jun-2020

57 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements