FED62. 使用 apply 调用函数
描述
实现函数 callIt,调用之后满足如下条件示例1
输入:
无
输出:
无
HTML/CSS/JavaScript 解法, 执行用时: 840ms, 内存消耗: 77772KB, 提交时间: 2020-12-05
{"css":"","js":"function callIt(fn) {\n return fn.apply(this,[].slice.call(arguments,1))\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 841ms, 内存消耗: 77772KB, 提交时间: 2020-12-26
{"css":"","js":"function callIt(fn) {\n let args = Array.prototype.slice.call(arguments, 1)\n return fn.apply(null, args)\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 841ms, 内存消耗: 77772KB, 提交时间: 2020-11-23
{"css":"","js":"function callIt(fn) {\n var arr=[];\n for(var i=1;i<arguments.length;i++){\n arr.push(arguments[i])\n }\n return fn.apply(callIt,arr)\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 843ms, 内存消耗: 77768KB, 提交时间: 2020-12-24
{"css":"","js":"function callIt(fn) {\n var args = Array.prototype.slice.call(arguments,1)\n return fn.apply(this,args)\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 844ms, 内存消耗: 77772KB, 提交时间: 2020-12-25
{"css":"","js":"function callIt(fn) {\n return fn.apply(null,Array.from(arguments).slice(1))\n}","html":"","libs":[]}