Why isn't the code `foo` displayed in the console? I expected the `foo` method in the child class to override the parent class. Why did that not happen?
function parent(){ }
parent.prototype.foo = function(){
console.log('foobar');
};
function child(){ }
child.prototype.foo = function(){
console.log('foo');
};
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = child;
console.log(new child().foo()); // foobar