Say I change the object prototype like so:
Object.prototype.test = {val: 5, abc: 8};
Then I change a property of test
for Array
:
Array.prototype.test.abc = 20;
Then if I print the base test
variable:
console.log(Object.prototype.test); // {val: 5, abc: 20}
console.log(({}).test); // {val: 5, abc: 20}
console.log(([]).test); // {val: 5, abc: 20}
How do I still have arrays inherit val
as 5, but have an abc
value of 20 without affecting Object
's prototype