如何在JavaScript中执行函数覆盖?JavaScript中的函数覆盖
我有以下代码。
function helloWorld() {
return 'helloworld ';
}
var origHelloWorld = window.helloWorld;
window.helloWorld = function() {
return 'helloworld2';
}
alert(helloWorld);
我想获得像
helloworld helloworld2
输出我该怎么办?
可能我描述的较少。其实我想打电话功能helloworld
,我想共同输出这两个功能。
呼叫从覆盖原始和结果追加到返回值。 – DarthJDG
也可以在警报的参数中调用重写。 – Teemu
你必须阅读关于JavaScript的原型,它可能会帮助你。 – sjahan