Reputation: 272
Is it possible to rename a predefined function in JavaScript as we do with php :
<?php
rename_function('mysql_connect', 'connect' );
?>
Upvotes: 1
Views: 2815
Reputation: 57650
It's possible in js too. See this function.
function rename_function(obj, oldf, newf){
obj[newf]=obj[oldf];
delete obj[oldf];
}
Here obj
is the closure of the function. Normally if your functions have no closure it's under window object. rename_function(window, 'alert', 'al')
Upvotes: 2