JavaScript极简入门教程(二):对象和函数(5)
复制代码 代码如下: Object.prototype.superior = function(name) { var that = this, method = that[name]; return function() { return method.apply(that, arguments); }; }; var coolcat = function (sp
复制代码 代码如下:
Object.prototype.superior = function(name) {
var that = this, method = that[name];
return function() {
return method.apply(that, arguments);
};
};
var coolcat = function (spec) {
// 获取子类的 get_name 方法
var that = cat(spec), super_get_name = that.superior('get_name');
that.get_name = function(n) {
return 'like ' + super_get_name() + ' baby';
};
return that;
};
精彩图集
精彩文章