Below is the sample JS code I have written to understand Function.prototype
<script>
function Foo() {
}
Foo.prototype = {
a: 9
};
var x = new Foo();
var y = new Foo();
console.log('x : ' + x.a + '\n');
console.log('y : ' + y.a + '\n');
x.a = 1;
console.log('x : ' + x.a + '\n');
console.log('y : ' + y.a + '\n');
</script>
I was expecting that the execution of above code will result in below output
x : 9 y : 9 x : 1 y : 1
But the actual output is
x : 9 y : 9 x : 1 y : 9
Can someone please explain why the last console.log prints 9 instead of 1.