Created
August 28, 2015 12:24
-
-
Save chuck0523/8c465653766e1109568b 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
// Generated by CoffeeScript 1.9.3 | |
(function() { | |
var AdminUser, SuperUser, User, bob, judy, log, | |
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; | |
log = function(x) { | |
return console.log(x); | |
}; | |
User = (function() { | |
function User(name) { | |
this.name = name; | |
} | |
User.prototype.hello = function() { | |
return log("hello, " + this.name); | |
}; | |
return User; | |
})(); | |
AdminUser = (function(superClass) { | |
extend(AdminUser, superClass); | |
function AdminUser() { | |
return AdminUser.__super__.constructor.apply(this, arguments); | |
} | |
return AdminUser; | |
})(User); | |
bob = new AdminUser("Bob"); | |
log(bob.name); | |
bob.hello(); | |
SuperUser = (function(superClass) { | |
extend(SuperUser, superClass); | |
function SuperUser() { | |
return SuperUser.__super__.constructor.apply(this, arguments); | |
} | |
SuperUser.prototype.hello = function() { | |
log("sudo "); | |
return SuperUser.__super__.hello.call(this); | |
}; | |
return SuperUser; | |
})(User); | |
judy = new SuperUser("judy"); | |
judy.hello(); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment