I have a bit of javascript that runs on a 3rd party's website which requires me to temporarily add a function to the Array type, e.g.
Array.prototype.foo = function() { alert("foo's for everyone!"); }; 
I want to be a good developer and not pollute the type systems of other people's code as much as possible so once the function is no longer needed I want to remove the function again. Is thi开发者_JS百科s possible?
You can use delete, which in general is good for removing all types of properties from objects: 
delete Array.prototype.foo;
Example: http://jsbin.com/iyamut
MDN Documentation: delete
Array.prototype.foo = undefined
or
delete Array.prototype.foo
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论