Created
February 23, 2016 08:36
-
-
Save astannard/067fe748081846a1656b to your computer and use it in GitHub Desktop.
Javascript function constructors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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