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: 2020-06-23T09:20:39+05:30

118 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements