Skip to content

Instantly share code, notes, and snippets.

@swaydeng
Last active December 21, 2015 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swaydeng/6291681 to your computer and use it in GitHub Desktop.
Save swaydeng/6291681 to your computer and use it in GitHub Desktop.
Add a property to Array.prototype and then delete it.
if (!Array.prototype.hello) {
Array.prototype.hello = function () {};
}
var arr = ['a', 'b', 'c'];
for (var k in arr) {
console.log(k + ' : ' + arr[k]);
}
delete Array.prototype.hello;
console.log('=====After delete=========');
for (var j in arr) {
console.log(j + ' : ' + arr[j]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment