Created
January 29, 2012 03:09
-
-
Save island205/1696948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var HanHan, HanJiaJun; | |
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { | |
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } | |
function ctor() { this.constructor = child; } | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor; | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
HanJiaJun = (function() { | |
/* | |
相当于JS中的构造函数 | |
*/ function HanJiaJun(name) { | |
this.name = name; | |
console.log("I am HanJiaJun!"); | |
} | |
/* | |
原型方法 | |
*/ | |
HanJiaJun.prototype.write = function(title) { | |
return "Original Article '" + title + "' form " + this.name; | |
}; | |
return HanJiaJun; | |
})(); | |
HanHan = (function() { | |
__extends(HanHan, HanJiaJun); | |
function HanHan() { | |
/* | |
相当于使用arguments直接apply父类的构造函数 | |
*/ HanHan.__super__.constructor.apply(this, arguments); | |
} | |
HanHan.prototype.write = function(title) { | |
return "A Copy of " + (HanHan.__super__.write.call(this, title)); | |
}; | |
return HanHan; | |
})(); | |
console.log(new HanHan("hanhan").write("人造方舟子")); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment