-1

I need to know the differences between these person1 and person2.

class Person {
  constructor(Firstname, Lastname) {
    this.Firstname = Firstname;
    this.Lastname = Lastname;;
  }
  display() {
    console.log(this.Firstname + " " + this.Lastname);
  }
}


const person1 = new Person("George", "Clooney");

const person2 = {
  Firstname: "George",
  LastName: "Clooney"
}
Jacob
  • 887
  • 1
  • 8
  • 17
Niroshan_Krish
  • 1,622
  • 2
  • 7
  • 11

1 Answers1

0

The first is instantiating a Person class, whereas the second is making an object. However, you have not provided anything about this Person class.

Jacob
  • 887
  • 1
  • 8
  • 17
  • person class has a constructor which initialize the FirstName and the LastName. And it also has a display method. – Niroshan_Krish Feb 17 '20 at 03:46
  • `class Person{ constructor(Firstname,Lastname){ this.Firstname=Firstname; this.Lastname=Lastname;; } display(){ console.log(this.Firstname+" "+this.Lastname); } }` – Niroshan_Krish Feb 17 '20 at 03:49