JavaScript Agregar propiedades y métodos en un objeto

// constructor function
function Person () {
    this.name = 'John',
    this.age = 23
}
// creating objects
let person1 = new Person();
let person2 = new Person();
// adding property to person1 object
person1.gender = 'male';
// adding method to person1 object
person1.greet = function () {
    console.log('hello');
}
person1.greet();   // hello

// Error code
// person2 doesn't have greet() method
person2.greet();
SAMER SAEID