Skip to content

Instantly share code, notes, and snippets.

@fredyang
Created October 29, 2012 02:54
Show Gist options
  • Save fredyang/3971215 to your computer and use it in GitHub Desktop.
Save fredyang/3971215 to your computer and use it in GitHub Desktop.
subclass array
//http://dean.edwards.name/weblog/2006/11/hooray/
// create an <iframe>
var iframe = document.createElement("iframe");
iframe.style.display = "none";
document.body.appendChild(iframe);
// write a script into the <iframe> and steal its Array object
frames[frames.length - 1].document.write(
"<script>parent.Array2 = Array;<\/script>"
);
alert(Array2 == Array); // => false
Array2.prototype.each = function(iterator) {
// iterate
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment