js 之 通用对象属性 与 通用对象方法
js的通用对象属性、方法:
- 通用对象属性:constructor、prototype
2.通用对象方法:valueOf()
constructor
返回对创建此对象的对应类型的函数的引用。
语法:
1.Array.constructor
2.Number.constructor
3.Boolean.constructor
4.Date.constructor
5.String.constructor
6.Math.constructor
prototype
prototype 属性使您有能力向对象添加属性和方法。
1.Array.prototype.name = value
2.Number.prototype.name = value
3.Boolean.prototype.name = value
4.Date.prototype.name = value
5.String.prototype.name = value
js原型与原型链
在了解原型与原型链时候,先记下以下几个要点:
1.所有的函数都有一个prototype属性;
2.所有的引用类型(数组、对象、函数),它的__proto__属性都指向他的构造函数的prototype属性