基本包装类型

基本包装类型就是把简单数据类型包装为复杂数据类型。

var str = 'andy';

console.log(str.length);

对象和复杂数据类型才有属性和方法,为什么这里会有length属性呢?

过程为:

var temp = new String('andy');   //包装为复杂数据类型

str = temp; //把临时变量的值给str

temp = null; //会自动销毁这个临时变量

posted on 2020-10-01 18:36  sbird  阅读(229)  评论(0)    收藏  举报

导航