Home  >  Article  >  Web Front-end  >  How to convert string to boolean in JavaScript?

How to convert string to boolean in JavaScript?

王林
王林forward
2023-09-03 08:17:021060browse

How to convert string to boolean in JavaScript?

#You can try running the following command to learn how to convert a string to a boolean value in JavaScript.

Example

Live Demonstration

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

The above is the detailed content of How to convert string to boolean in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete