Last active
September 29, 2015 07:57
-
-
Save SparK-Cruz/1570177 to your computer and use it in GitHub Desktop.
JavaScript Class boilerplate
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
| /** | |
| * JavaScript Class Definition | |
| * | |
| * Author: Roger "SparK" Rodrigues da Cruz | |
| * Licence: Free, no credits, no references, just use it if you feel like. | |
| */ | |
| ;MyClass = (function(){ | |
| var C = function(){ return constructor.apply(this,arguments); } | |
| var p = C.prototype; | |
| //list the attributes | |
| p.name; | |
| //construct | |
| function constructor(name){ | |
| this.name = name; | |
| } | |
| //define methods | |
| p.askName = function(){ | |
| return "Hello, my name is "+this.name; | |
| } | |
| //unleash your class | |
| return C; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment