Skip to content

Instantly share code, notes, and snippets.

@ipmsteven
Created February 4, 2015 08:57
Show Gist options
  • Select an option

  • Save ipmsteven/ecf623802eda074534b5 to your computer and use it in GitHub Desktop.

Select an option

Save ipmsteven/ecf623802eda074534b5 to your computer and use it in GitHub Desktop.
js new
var Class = function(){
var klass = function(){
this.init.apply(this, arguments);
};
klass.prototype.init = function(){};
return klass;
};
// Case 1
var Person = new Class;
Person.prototype.init = function(){
// Called on Person instantiation
};
// Usage:
var person = new Person;
// Case 2
var Person = Class();
Person.prototype.init = function(){
// Called on Person instantiation
};
// Usage:
var person = new Person;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment