My app (a custom web browser) is injecting code into a page that has a modified Array
prototype (specifically because it uses prototype.js). I would like to ensure that the code I inject uses the normal Array
. I am using the code from https://stackoverflow.com/a/15147986/502149 to reset the prototype, and this works fine if I say:
(function(Array) {
var array = new Array();
)(ArrayWithUnmodifiedPrototype);
However, I still get the modified prototype if I say:
(function(Array) {
var array = [];
)(ArrayWithUnmodifiedPrototype);
I'm not sure if this is going to be a problem (some third-party libraries in the code I inject could theoretically use []
) but either way I'm curious: is there any way to override []
so it uses a different prototype than that of the current Array.prototype
in global scope?