I am a bit lost and/or too naive. I's like to create an Object with a prototype object holding a function which adds a value to a list created as a property.
But it seems that Object.create ignores the creation of the property. At least, that's what I am making of it.
What is it I am not getting?
Here's an example:
const proto = {
add(s) {
this.list.push(s);
}
}
const props = {
list: []
}
const newObj = Object.create(proto, props);
console.log('newObj', newObj);
// What happendened to the list property?
newObj.add('test');
// due to undefined list-Property
// an error is being thrown