Last active
August 29, 2015 14:03
-
-
Save marshluca/36f7e7627945fc53175c to your computer and use it in GitHub Desktop.
define a module with `class` in 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
class @MyModule | |
@init: -> | |
alert "Init MyModule" | |
return | |
MyModule.init() | |
class MyClass | |
constructor: (name) -> | |
@name = name | |
init: -> | |
alert @name | |
return | |
myClass = new MyClass("Lucas") | |
myClass.init() |
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 MyClass, myClass; | |
this.MyModule = (function() { | |
function MyModule() {} | |
MyModule.init = function() { | |
alert("Init MyModule"); | |
}; | |
return MyModule; | |
})(); | |
MyModule.init(); | |
MyClass = (function() { | |
function MyClass(name) { | |
this.name = name; | |
} | |
MyClass.prototype.init = function() { | |
alert(this.name); | |
}; | |
return MyClass; | |
})(); | |
myClass = new MyClass("Lucas"); | |
myClass.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment