Created
December 9, 2019 19:57
-
-
Save sjbarag/f364bf64a88e928d03a4b51c89b80071 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
var Foo, f, | |
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | |
extend = 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; }, | |
hasProp = {}.hasOwnProperty; | |
Foo = (function(superClass) { | |
extend(Foo, superClass); | |
function Foo() { | |
this.sayHello = bind(this.sayHello, this); | |
return Foo.__super__.constructor.apply(this, arguments); | |
} | |
Foo.prototype.sayHello = function(name) { | |
return console.log("Hello, " + name + "!"); | |
}; | |
return Foo; | |
})(Bar); | |
f = new Foo(); | |
setImmediate(function() { | |
return f.sayHello("Dave"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment