new instance of object javascript code example
Example 1: create nodejs new object
class Person {
constructor(fname, lname) {
this.firstName = fname;
this.lastName = lname;
}
}
const person = new Person('testFirstName', 'testLastName');
console.log(person.firstName);
console.log(person.lastName);
Example 2: new instance of object javascript
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
var car1 = new Car('Eagle', 'Talon TSi', 1993);
console.log(car1.make);