Javascriptでは、コードの特定のセクションで関数が呼び出されないようにする方法はありますか?コードの特定のセクションで関数「alert」が呼び出されないようにしたい。
alert("Hi!"); //this should work normally
var al = alert
//the function "alert" cannot be called after this point
preventFunctionFromBeingCalled(alert, "Do not use alert here: use the abbreviation 'al' instead.");
alert("Hi!"); //this should throw an error, because "console.log" should be used instead here
allowFunctionToBeCalled(alert);
//the function "alert" can be called after this point
alert("Hi!"); //this should work normally
この場合、どのように関数を実装する必要がallowFunctionToBeCalled
ありpreventFunctionFromBeingCalled
ますか?