Skip to content

Instantly share code, notes, and snippets.

@jomontanari
Created April 23, 2012 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jomontanari/2468379 to your computer and use it in GitHub Desktop.
Save jomontanari/2468379 to your computer and use it in GitHub Desktop.
Code snippets for ThoughtWorks Team Hug presentation - comparing JavaScript and CoffeeScript (part 1)
var myTeamHugSession = {
title: "CoffeeScript",
time: {
start: "2:30pm",
finish: "3:30pm"
}
};
myTeamHugSession =
subject: "CoffeeScript”
time:
start: "2:30pm”
end: "3:30pm"
function startPresentation(subject) {
alert("A presentation about " + subject + " is now starting!");
}
var startPresentation = function(subject) {
alert("A presentation about " + subject + " is now starting!");
};
startPresentation("JavaScript");
startPresentation = (subject) ->
alert "A presentation about " + subject + " is now starting!"
startPresentation "CoffeeScript"
var description = "This is a talk about " + myPresentation.subject + " by " + myPresentation.presenter + ". It will start at " + myPresentation.startTime + " and finish by " + myPresentation.endTime;
description = "This is a talk about #{myPresentation.subject} by #{myPresentation.presenter}. It will start at #{myPresentation.startTime} and finish by #{myPresentation.endTime}"
var TeamHugPresentation = function(title, presenter) {
this.getHeadline = function() {
return title + " by " + presenter;
};
this.showHeadline = function() {
alert(this.getHeadline());
};
};
class TeamHugPresentation
constructor: (@title, @presenter) ->
getHeadline: ->
"#{@title} by #{@presenter}"
showHeadline: ->
alert(@getHeadline())
function add(x, y) {
return x + y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment