Created
January 11, 2012 13:48
-
-
Save peterhughesdev/1594731 to your computer and use it in GitHub Desktop.
Resig's Class.extend minified
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
var Class = function(){var d=!1,g=/xyz/.test(function(){})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(b){function c(){!d&&this.init&&this.init.apply(this,arguments)}var e=this.prototype;d=!0;var f=new this;d=!1;for(var a in b)f[a]="function"==typeof b[a]&&"function"==typeof e[a]&&g.test(b[a])?function(a,b){return function(){var c=this._super;this._super=e[a];var d=b.apply(this,arguments);this._super=c;return d}}(a,b[a]):b[a];c.prototype=f;c.prototype.constructor=c;c.extend=arguments.callee; return c};return Class}(); |
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
var Foo = Class.extend({ | |
init: function() { | |
this.foo = "bar"; | |
} | |
}); | |
var FooTwo = Foo.extend({ | |
init: function() { | |
this._super(); | |
this.foo2 = "bar2"; | |
} | |
}); | |
var f = new Foo(); | |
var f2 = new FooTwo(); | |
console.log( f.foo ); | |
console.log( f.foo2 ); | |
console.log( f2.foo ); | |
console.log( f2.foo2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment