var a="123"
var b=String("123")
typeof a是string
typeof b是object
但是a也有string对象的那些方法啊
那么他们之间有什么不同呢

解决方案 »

  1.   

    String和string有什么不同,你知道吗?
    String是对象,string是实例
      

  2.   

    js有类型自动转换功能,会根据上下文自动转换变量的类型。The basic rule is that when a value of one type is used in a context that requires a value of some other type, JavaScript automatically attempts to convert the value as needed
      

  3.   

    lz 结帖率:0.00% typeof 运算符
    返回一个用来表示表达式的数据类型的字符串。结合 #4 的解释,typeof 只能说明【表达式的数据类型】,即数据特性,
    而对象特性,是通过 constructor 来体现的!var a1 = "123";
    var a2 = new String("123");
    alert(typeof a2.valueOf()); // string
    alert(a1.constructor === a2.constructor); // true
      

  4.   

    Web 开发常用手册JScript语言参考.rar
    http://download.csdn.net/source/308916DHTML参考手册.rar
    http://download.csdn.net/source/308913样式表中文手册.chm
    http://download.csdn.net/source/304124
      

  5.   

    其实就是自动装箱。
    string在JavaScript里是一个基本类型,有个对应的String包装类。