Created
October 13, 2011 18:51
-
-
Save gonzalo123/1285122 to your computer and use it in GitHub Desktop.
Example static and non static functions
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 Dummy | |
| @helloStatic: (name)-> | |
| "hello #{name} (static)" | |
| hello: (name) -> | |
| "hello #{name}" | |
| alert Dummy.helloStatic("Gonzalo") | |
| dummy = new Dummy | |
| alert dummy.hello("Gonzalo") |
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 Dummy, dummy; | |
| Dummy = (function() { | |
| function Dummy() {} | |
| Dummy.helloStatic = function(name) { | |
| return "hello " + name + " (static)"; | |
| }; | |
| Dummy.prototype.hello = function(name) { | |
| return "hello " + name; | |
| }; | |
| return Dummy; | |
| })(); | |
| alert(Dummy.helloStatic("Gonzalo")); | |
| dummy = new Dummy; | |
| alert(dummy.hello("Gonzalo")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment