public
Created

Budapest.js meetup presentation codes (2013-01-14)

  • Download Gist
class-sample.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# CoffeeScript code
class Greeter
constructor: (@greeting) ->
 
greet: (name) ->
console.log @greeting + name
 
class AllGreeter extends Greeter
constructor: (greeting, @names) ->
super greeting
 
greetAll: () ->
@names.forEach (name) =>
@greet(name)
class-sample.ts
TypeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// TypeScript code
class Greeter {
constructor(public greeting: string) {}
 
greet(name: string) {
console.log(this.greeting + name);
}
}
 
class AllGreeter extends Greeter {
constructor(greeting: string, public names : string[]) {
super(greeting)
}
 
greetAll() {
this.names.forEach((name) => {
this.greet(name);
});
}
}
compiled-coffeescript.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
// compiled CoffeeScript code (with unified indentation)
var __hasProp = {}.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; };
 
 
 
var Greeter = (function () {
 
function Greeter(greeting) {
this.greeting = greeting;
}
 
Greeter.prototype.greet = function (name) {
return console.log(this.greeting + name);
};
 
return Greeter;
})();
 
var AllGreeter = (function (_super) {
 
__extends(AllGreeter, _super);
 
function AllGreeter(greeting, names) {
this.names = names;
AllGreeter.__super__.constructor.call(this, greeting);
}
 
AllGreeter.prototype.greetAll = function () {
var _this = this;
return this.names.forEach(function (name) {
return _this.greet(name);
});
};
 
return AllGreeter;
})(Greeter);
compiled-typescript.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
// compiled TypeScript code (with unified indentation)
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
 
var Greeter = (function () {
 
function Greeter(greeting) {
this.greeting = greeting;
}
 
Greeter.prototype.greet = function (name) {
console.log(this.greeting + name);
};
 
return Greeter;
})();
 
var AllGreeter = (function (_super) {
 
__extends(AllGreeter, _super);
 
function AllGreeter(greeting, names) {
this.names = names;
_super.call(this, greeting);
}
 
AllGreeter.prototype.greetAll = function () {
var _this = this;
this.names.forEach(function (name) {
_this.greet(name);
});
};
 
return AllGreeter;
})(Greeter);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.