public
Created

  • Download Gist
javascript.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
var Thing;
var __hasProp = Object.prototype.hasOwnProperty, __extends = 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;
};
Thing = (function() {
__extends(Thing, EventEmitter);
function Thing(name) { //this constructor function is the scope of `name`
this.getName = function() { //but `this` is what the constructor returns, so this method is public
return name;
};
}
return Thing;
})();
original.coffee
CoffeeScript
1 2 3
class Thing extends EventEmitter
constructor: (name) ->
@getName = -> name

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.