Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created June 13, 2018 07:27
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 Kcko/8128f718a67dcff1614640e48bd2db20 to your computer and use it in GitHub Desktop.
Save Kcko/8128f718a67dcff1614640e48bd2db20 to your computer and use it in GitHub Desktop.
1)
var Abc = function(aProperty,bProperty){
this.aProperty = aProperty;
this.bProperty = bProperty;
this.init = function(){
// Do things here.
}
this.init();
};
var currentAbc = new Abc(obj,obj);
2)
var Abc = function(aProperty,bProperty){
function privateInit(){ console.log(this.aProperty);}
this.aProperty = aProperty;
this.bProperty = bProperty;
privateInit.apply(this);
};
3)
var Abc = function(aProperty,bProperty){
this.aProperty = aProperty;
this.bProperty = bProperty;
//init
(function () {
// Perform some operation
}.call(this));
};
var currentAbc = new Abc(obj,obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment