在 JavaScript 中将 { } 转换为 String 会发生什么?

htmljavascriptprogramming scripts

使用 JavaScript 中的 String() 方法转换为 String。您可以尝试运行以下代码来了解如何在 JavaScript 中将 { } 转换为 String。

示例

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

相关文章