Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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