Changing the property of base object

I have an example, after the line toy.type = 'break';I was expecting the next line would give me the value as “break” but instead gave “soft”. Why isnt changing the parent property not reflecting when accessed using child object . Isnt the prototypal inheritance just a refernce to the base object?

const toy = {
    init : function(type)
    this.type = type
  display : function()

const softToy = Object.create(toy);
toy.type = 'break';


When you access an object, JavaScript searches up the prototype chain until it finds an object with that property.

Because softToy has its own type property, you get the value of that. If it didn’t have its own type property then the prototype chain would be followed to the toy object and the type property from there would be accessed instead.

In other words, you get the closest version of the property not the most recently changed version.