I am only starting to learn JavaScript and encounered with a problem trying to understand how the prorotypes work.
I got the following code
var parent = {
city : "Cardiff",
hair : "white",
surname : "Smith",
name : "John"
};
var child = Object.create(parent);{
name : "Mike"
};
child.name
And when I call child.name
it returns me John
and not Mike
.
I tried to google, change the code, browsed through some reference books but still can't find the reason why am I returned John
.