Skip to content

Instantly share code, notes, and snippets.

@scribblet
Forked from calvinmetcalf/constructor.js
Last active January 1, 2016 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scribblet/8093581 to your computer and use it in GitHub Desktop.
Save scribblet/8093581 to your computer and use it in GitHub Desktop.
function myThing(){
if(!(this instanceOf myThing)){
return new myThing();
}
var private = 'blah';
var api = this;
api.methodOne = function(params){
if(private){
//...
}
};
api.methodTwo = function(params){
var something = api.methodOne(stuff);
//...
};
}
@scribblet
Copy link
Author

Constructor pattern (compared to module)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment