Created
September 4, 2012 08:22
-
-
Save thehydroimpulse/3618465 to your computer and use it in GitHub Desktop.
Javascript vs Coffeescript
This file contains 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 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 |
This file contains 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 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