var str1= new string("hello");
var str2 = new string("hello");
str1 == "hello" ; // true
str2 == "hello";// true
str1 != str2 // true ?????? why?
var str2 = new string("hello");
str1 == "hello" ; // true
str2 == "hello";// true
str1 != str2 // true ?????? why?
str1.toString() != str2.toString(); //这样就false了另外,创建字符串对象应该是 new String(),大小写敏感的。
alert(typeof(str1)) 看看,结果就是 "object"
也就是说 str1放的是一个指针,指像一个对象
str1和 str2指向的对象完全不一样所以str1自然就不等于str2了
LZ看完就明白了