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

原创
ithorizon 5个月前 (10-19) 阅读数 49 #HTML

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

示例

现场演示

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

以上就是当在JavaScript中将1转换为布尔值时会发生什么?的详细内容,更多请关注IT视界其它相关文章!



热门