In Chrome, try the following in the console. First
console = 0;
to assign the value 0 to console. Then
console // (prints `0`)
to check we have correctly overwritten console. Finally,
delete console
Surprisingly, console now holds the original Console object. In effect, the delete keyword “resurected” console, instead of exterminating it!
Is this expected behaviour? Where is this implemented in the Chromium code?
As mentioned in MDN’s documentation on
delete:Your
deletesimply unshadows native property inherited through prototype chain.Some browsers have
windowinherit from native prototype and you’ll have check out sources to see how property is inherited, if you really want to know that much details, but mostly they work just like JS’ own.