Skip to content

Instantly share code, notes, and snippets.

@thehydroimpulse
Created September 4, 2012 08:22
Show Gist options
  • Save thehydroimpulse/3618465 to your computer and use it in GitHub Desktop.
Save thehydroimpulse/3618465 to your computer and use it in GitHub Desktop.
Javascript vs Coffeescript
class Person
@name: null
@age: 18
constructor: (@name, @age) ->
if @name == 'Hello'
$(".name").html "Yeah, you made it!"
if @age > 18
$(".age").html "Welcome home!@"
setAge(@age) ->
setName(@name) ->
getAge() ->
@age
getName() ->
@name
var Person;
Person = (function() {
Person.name = null;
Person.age = 18;
function Person(name, age) {
this.name = name;
this.age = age;
if (this.name === 'Hello') {
$(".name").html("Yeah, you made it!");
}
if (this.age > 18) {
$(".age").html("Welcome home!@");
}
}
setAge(Person.age)(function() {});
setName(Person.name)(function() {});
getAge()(function() {
return this.age;
});
getName()(function() {
return this.name;
});
return Person;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment