您可以尝试运行以下代码来了解如何在 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转换为布尔值时会发生什么?的详细内容。