Created
August 19, 2014 13:48
-
-
Save yardfarmer/f3561136754092e443e3 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
/** | |
* Class build my Own class | |
* Created by cyk on 14-8-19. | |
*/ | |
/* | |
* 很巧妙的办法 | |
*/ | |
var Class = function() { | |
"use strict"; | |
var klass = function() { | |
// this 均是上下文中新生成的实例 | |
this.init.apply(this, arguments); | |
}; | |
klass.prototype.init = function() {}; | |
return klass; | |
}; | |
var Person = new Class(); | |
Person.prototype.init = function() { | |
"use strict"; | |
}; | |
var person = new Person(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment