在中间的注释那里补充代码使这个代码输出最后的注释内容,谢谢大牛
var A = function() {
this.name = 'apple';
}
A.prototype.getName = function() {
return this.name;
}
// 补充代码
var B = A.extend({
initialize: function() {
this.superclass.initialize.call(this);
this.total = 3;
},
say: function() {
return '我有' + this.total + '个' + this.getName()
}
});
var b = new B();
console.log(b.say()); //我有3个apple
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Function.prototype.extend= Function.prototype.extend || function(obj) {
}
注:这块代码放在其他可行位置都是可以的哦~~~~
我替一位哥们儿写的(我只是个搬运工,逃~)
试着回答了一下,太烧脑了。
我的思路来自 ES6 Classes 的 ES5 实现
https://github.com/addyosmani...
效果是达到了,不过有些别扭。