The method of overriding the Window object is not a novelty, for example, we may need to change the behavior of the default alert, how to rewrite it safely?
Side dishes see a well-known it web site is such a way to:
Window.alert = function () {};
Or
alert = function () {};
In fact, the wording is somewhat defective. This is equivalent to adding an alert property on the Window object that has a higher priority than the system's built-in alert, so it can be overridden, but it's easy to break through and the following statement will restore alert.
Delete Window.alert;
Because alert overridden in this way is only a property of the Window object, it can be deleted by the delete operator.
How can it be permanently rewritten and irreversible?
Just define a global variable! The global variable, although it is also registered as a property of the Window object, cannot be deleted, and it is virtually absolute. The code is as follows:
var alert = function () {};
This method of rewriting is absolutely not to be restored, safe and reliable!