Created
February 15, 2016 15:38
-
-
Save catacs/9f09ae06a0334f6ff5ed to your computer and use it in GitHub Desktop.
Class pattern javascipt
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
// Constructor | |
var Class = function (value1, value2) { | |
this.value1 = value1; | |
}; | |
// properties and methods | |
Class.prototype = { | |
value1: 'default_value', | |
method: function (argument) { | |
this.value2 = argument + 100; | |
}, | |
}; | |
// node.js module export | |
module.exports = Class; | |
// constructor call | |
var object = new Class('Hello', '2'); | |
// http://blog.mixu.net/2011/02/02/essential-node-js-patterns-and-snippets/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment