xxxxxxxxxx
Invalid cases
const Car = 1;
new Car();
// TypeError: Car is not a constructor
new Math();
// TypeError: Math is not a constructor
new Symbol();
// TypeError: Symbol is not a constructor
function* f() {};
const obj = new f;
// TypeError: f is not a constructor
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
Now you can create an object called mycar as follows:
const mycar = new Car('Eagle', 'Talon TSi', 1993);