标签导航:

当在javascript中将1转换为布尔值时会发生什么?

您可以尝试运行以下代码来了解如何在 JavaScript 中将 1 转换为布尔值 -

示例

现场演示

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