Created
April 23, 2012 02:28
-
-
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)
This file contains hidden or 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
| var myTeamHugSession = { | |
| title: "CoffeeScript", | |
| time: { | |
| start: "2:30pm", | |
| finish: "3:30pm" | |
| } | |
| }; |
This file contains hidden or 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
| myTeamHugSession = | |
| subject: "CoffeeScript” | |
| time: | |
| start: "2:30pm” | |
| end: "3:30pm" |
This file contains hidden or 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
| 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"); |
This file contains hidden or 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
| startPresentation = (subject) -> | |
| alert "A presentation about " + subject + " is now starting!" | |
| startPresentation "CoffeeScript" |
This file contains hidden or 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
| var description = "This is a talk about " + myPresentation.subject + " by " + myPresentation.presenter + ". It will start at " + myPresentation.startTime + " and finish by " + myPresentation.endTime; |
This file contains hidden or 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
| description = "This is a talk about #{myPresentation.subject} by #{myPresentation.presenter}. It will start at #{myPresentation.startTime} and finish by #{myPresentation.endTime}" |
This file contains hidden or 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
| var TeamHugPresentation = function(title, presenter) { | |
| this.getHeadline = function() { | |
| return title + " by " + presenter; | |
| }; | |
| this.showHeadline = function() { | |
| alert(this.getHeadline()); | |
| }; | |
| }; |
This file contains hidden or 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
| class TeamHugPresentation | |
| constructor: (@title, @presenter) -> | |
| getHeadline: -> | |
| "#{@title} by #{@presenter}" | |
| showHeadline: -> | |
| alert(@getHeadline()) |
This file contains hidden or 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
| function add(x, y) { | |
| return x + y; | |
| } |
This file contains hidden or 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
| add: (x, y) -> | |
| x + y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment