Skip to content

Instantly share code, notes, and snippets.

@astannard
Created February 23, 2016 08:36
Show Gist options
  • Save astannard/067fe748081846a1656b to your computer and use it in GitHub Desktop.
Save astannard/067fe748081846a1656b to your computer and use it in GitHub Desktop.
Javascript function constructors
//Function constructors use the New keyward that create a new object in memory that then becomes the this scope inside of the contructor functoim
//Using the prototype syntax to add methods to the constructed object means that multiple objects take up less memoryspace since a new copy of
//each function is not added into memory space for each object.
function Person(firstname, lastname){
this.firstname = firstname;
this.lastname = lastname;
}
var varl = new Persion('carl','brown');
Person.ProtoType.getFullName() = new function(){
return this.firstname + ' ' + this.lastname;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment