A property descriptor is an options object passed to Object.defineProperty to specify a property's attributes. Descriptors can control enumeration and define accessors that run getters or setters when the property is read or written. section 9.1.2
Object.defineProperty(ninjaCollection, "firstNinja", {
enumerable: true,
get() {
console.log(`Getting firstNinja: ${this.ninjas[0]}`);
return this.ninjas[0];
},
set(newNinja: string) {
console.log(`Setting firstNinja: ${newNinja}`);
this.ninjas[0] = newNinja;
},
});
This descriptor makes firstNinja enumerable and uses a getter and setter to read and update the first item in ninjas. section 9.1.2


