Created
March 17, 2018 12:32
-
-
Save linx4200/e1b435bee766c81253c335c5fa4a83fa to your computer and use it in GitHub Desktop.
【继承】原型式继承
This file contains hidden or 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 inheritObject(o) { | |
// 声明一个过渡函数对象 | |
function F () {}; | |
// 过渡对象的原型继承父对象 | |
F.prototype = o; | |
// 返回过渡对象的一个实例 | |
return new F(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment