Skip to content

Instantly share code, notes, and snippets.

@allanesquina
Created May 20, 2015 22:46
Show Gist options
  • Save allanesquina/50934195d36d0e22bd2e to your computer and use it in GitHub Desktop.
Save allanesquina/50934195d36d0e22bd2e to your computer and use it in GitHub Desktop.
// Object construcion exemple
function MyClass() {
this.myProperty = 'foo';
}
// Whitout new
var myInstance = {};
MyClass.call( myInstance );
console.log( 'without ' + myInstance.myProperty );
// Whit new
var myInstance = new MyClass();
console.log( 'with: ' + myInstance.myProperty );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment