如何重命名javascript预定义函数 [英] How to rename javascript predefined functions
本文介绍了如何重命名javascript预定义函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以像使用php一样重命名JavaScript中的预定义函数:
Is it possible to rename a predefined function in JavaScript as we do with php :
<?php
rename_function('mysql_connect', 'connect' );
?>
推荐答案
在js中也可能.请参阅此功能.
It's possible in js too. See this function.
function rename_function(obj, oldf, newf){
obj[newf]=obj[oldf];
delete obj[oldf];
}
此处obj
是该函数的关闭.通常,如果您的函数没有闭包,则它位于window对象下. rename_function(window, 'alert', 'al')
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')
这篇关于如何重命名javascript预定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文