JavaScript 比较运算符问题
《HTML权威指南》一书中有这样一段Javascript代码:程序代码:
<!DOCTYPE HTML> <html> <head> <title>Example</title> </head> <body> <script type="text/javascript"> var myData1={ name:"Adam", weather:"sunny", }; var myData2={ name:"Adam", weather:"sunny", } var myData3=myData2; var test1=myData1==myData2; var test2=myData2==myData3; var test3=myData1===myData2; var test4=myData2===myData3; document.writeln("Test 1:"+test1+" Test 2:"+test2); document.writeln(" Test 4:"+test3+" Test 4:"+test4); </script> </body> </html>其中
var test1=myData1==myData2;定义变量test1的值为 myData1与myData2相比较的返回值。
myData1与myData2的字符串不是相同的吗?比较的返回值应该是true啊,为什么是false?
请教大神指点,多谢!