1
2
3
4
5
6
const a = 18;
console.log(a.toString())// "18"
//===等价于===(js引擎做的事)
const a = 18;
const tmpAObject = new Number(a);
console.log(tmpAObject.toString())// "18"

包装类型与引用类型的不同

  • 包装类型只会在执行瞬间被创建,调用后被销毁。
1
2
3
4
5
6
7
const person = {
name: "zhangsan",
age: 18
}
console.log(person.age)// 18
//======