<script type="text/javascript"> function Add(x,y) { alert(x + y); } function Sub(x,y) { alert(x - y); } function CallFunc(Fun, x, y) { if (Fun && (typeof Fun == "function")) { //判断是否是过程 if (x && y && (typeof x == "number") && (typeof y == "number")) { //判断是否是数值型 Fun(x,y); }else { console.log(typeof x); } }else { } } CallFunc(Sub, 5.5, 3); </script>
js传递函数作为参数
最新推荐文章于 2023-07-19 21:03:24 发布