精选的有用的JavaScript代码片段
片段用ES6编写,使用Babel transpiler来确保向后兼容性。
目录
Adapter(适配器)
View contentsdapter(适配器)
ary
返回一个函数,这个函数可以接收n个参数,并过滤掉额外的参数。
然后调用传入的函数fn
,通过调用args.slice(0, n)
最多有n个参数
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
精选的有用的JavaScript代码片段
片段用ES6编写,使用Babel transpiler来确保向后兼容性。
返回一个函数,这个函数可以接收n个参数,并过滤掉额外的参数。
然后调用传入的函数fn
,通过调用args.slice(0, n)
最多有n个参数
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
转载于:https://www.cnblogs.com/angelwgh/p/8979216.html