Answers for "new instance of object javascript"

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); // testFirstName
console.log(person.lastName); // testLastName
Posted by: Guest on November-28-2020
1

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);
// expected output: "Eagle"
Posted by: Guest on December-01-2019

Code answers related to "new instance of object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language