利用 call() 或 apply() 方法,在子构造函数 Child() 中,调用 Person.call(this, name) ,增强子构造函数实例;实质等同于复制父实例给子函数。 1.1代码实现 function Person(name) { this.name = name; this.names = ; this.getName = function () { console...
利用 call() 或 apply() 方法,在子构造函数 Child() 中,调用 Person.call(this, name) ,增强子构造函数实例;实质等同于复制父实例给子函数。 1.1代码实现 function Person(name) { this.name = name; this.names = ; this.getName = function () { console...