Skip to content

Instantly share code, notes, and snippets.

@catacs
Created February 15, 2016 15:38
Show Gist options
  • Save catacs/9f09ae06a0334f6ff5ed to your computer and use it in GitHub Desktop.
Save catacs/9f09ae06a0334f6ff5ed to your computer and use it in GitHub Desktop.
Class pattern javascipt
// 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