PRO CODE Asked:2021-12-22 05:41:22 +0800 CST2021-12-22 05:41:22 +0800 CST 2021-12-22 05:41:22 +0800 CST js函数怎么写 [复制] 772 如何在js中编写一个函数(a),通过这样的调用:a(1)(2)(3)将所有数字相乘将显示6?我会很感激。 javascript 1 个回答 Voted Best Answer entithat 2021-12-22T06:06:10+08:002021-12-22T06:06:10+08:00 function foo(n) { function bar(arg) { n *= arg; return bar; } bar.toString = function() { return n; } return bar; } console.log(foo(1)); console.log(foo(1)(2)(3)); console.log(foo(1)(2)(3)(4));
1 个回答