Waypoint Construct JavaScript Objects with Functions - GJSmith3rd/FreeCodeCamp-BootCamp GitHub Wiki
Contact me
Gilbert Joseph Smith III
Github | FreeCodeCamp | CodePen | LinkedIn | Blog/Site | E-Mail
Construct JavaScript Objects with Functions
Another way to create objects is with constructors. I particularly like them because them you can create more objects using them as a base.
// Let's add the properties engines and seats to the car in the same way that the property wheels has been added below. They should both be numbers.
var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 1;
};
var myCar = new Car();