运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript String Objects</h2> <p>Never create strings as objects.</p> <p>Strings and objects cannot be safely compared.</p> <p id="demo"></p> <script> let x = "John"; // x is a string let y = new String("John"); // y is an object document.getElementById("demo").innerHTML = (x === y); </script> </body> </html>