Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (18 sloc) 523 Bytes

Make Unique Objects by Passing Parameters to our Constructor

When you have a constructor but don't want to keep creating the same object, all you have to do is add parameters to the constructor the following way:

var Car = function(wheels, seats, engines) {

  this.wheels = wheels;

  this.seats = seats;

  this.engines = engines;

};

Now you can pass in arguments when you call the constructor. var myCar = new Car(6, 3, 1);

This will result in:

{

  wheels: 6,

  seats: 3,

  engines: 1

}
Something went wrong with that request. Please try again.