1,demo1:参数function无参
<script>
function fun1(){
fun3('fun4');
}
function fun2(){
fun3('fun5');
}
function fun3(fun){
eval(fun+'()');
}
function fun4(){
alert("fun4")
}
function fun5(){
alert("fun5")
}
</script>
<button onclick="fun1()">button1</button>
<button onclick="fun2()">button2</button>
2,demo2:参数function有参
<script>
function fun1(){
fun3('fun4',"param4");
}
function fun2(){
fun3('fun5',"param5");
}
function fun3(fun,param){
eval(fun+'("'+param+'")');
}
function fun4(param){
alert(param)
}
function fun5(param){
alert(param)
}
</script>
<button onclick="fun1()">button1</button>
<button onclick="fun2()">button2</button>