A bit of a JavaScript newbie here. I have the following 2 JavaScript code snippets here which does not do what I am expecting. The examples create an instance of the object "Person" in Example #1 using the "new" operator, and creates a prototype of "Person" in Example #2 using the ES5 Object.create() property.
let Person = function(name, age, city) {
this.name = name;
this.age = age;
this.city = city
}
// Using 'new' operator (working)
let person1 = new Person("Jack Rabit", 40, "Seattle");
Object.values(person1); // Shows "Jack Rabit", 40, "Seattle"
But, doing the following using the Object.create() property...does not show the first value of the Property (in this case "name"):
let person2 = Object.create(Person);
person2.name = "Will";
person2.age=41;
person2.city="San Jose";
Object.values(person2); // Shows 41, "San Jose" (Does NOT show the value of the "name" property)
What is that I am missing?