包装类
原始类调用属性和方法时隐式发生(undefind,null 不能包装类-----因为他们没有原型)
数据:
-
原始类型(string,number,null,boolean,undefind,symbol[符号---独一无二的数据],bigint[大整数])
-
不能有属性和方法。
-
-
对象类型(object)
-
new ...(类型)本身没有该类型
var num = 4; num.le = 3;//new Number(4).le = 3; delete; console.log(num.le);//new Number(4).le; delete; //因为前一个已经销毁,而后一个有没有进行赋值,所以输出“undefind"
-
其中 new ...(类型)本身就有该属性
var str = "abcd";
str.length = 2;
console.log(str.length);
//输出”4“
//因为字符串new string('abcd').length = 4;这里的length是对象字符串本身有的属性
-
因为绝大多数的对象都可以继承自Object.prototype,所以绝大多数包装类都可以调用Object.prototype中的属性或方法
//比如:toString var num = 123; console.log(num.toString())//输出:“123”(字符串)----因为new number().prototype,其中有toString() //注意 //console.log(123.toString())//会报错,因为这里的"."会优先被识别成小数点