JSFiddle - React, Tailwind, and code Playground

by akang2

JavaScript

//Act 7.6 Learning about Constructor Functions

//Constructor functions are functions that allow us to create objects in a new way. What's so special about this way is that we can create an object that has no values. This is useful if we don't know the values of an object yet, but want to create the structure of it so that we can be ready when we DO get the values


function Car (make, model, year) {
    this.make = make;
    this.model = model;
    this.year = year;
}


var myRide = new Car('chevy', 'silverado', 2003);

//this shows us the make of the car we created above
console.log(myRide.make);

//Unfortunately we have to assign our Car to a variable name, and then we use that variable name to access the object properties