源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>不要创建字符串作为对象.</p> <p>JavaScript 无法比较的对象.</p> <p id="demo"></p> <script> var x = new String("John"); var y = new String("John"); document.getElementById("demo").innerHTML = x==y; </script> </body> </html>
运行结果