实现一个函数,该函数接受一个或多个值,并返回一个函数,该函数在每次调用时循环遍历这些值。
const helloFn = cycle('hello');console.log(helloFn()); // "hello"console.log(helloFn()); // "hello"const onOffFn = cycle('on', 'off');console.log(onOffFn()); // "on"console.log(onOffFn()); // "off"console.log(onOffFn()); // "on"
实现一个函数,该函数接受一个或多个值,并返回一个函数,该函数在每次调用时循环遍历这些值。
const helloFn = cycle('hello');console.log(helloFn()); // "hello"console.log(helloFn()); // "hello"const onOffFn = cycle('on', 'off');console.log(onOffFn()); // "on"console.log(onOffFn()); // "off"console.log(onOffFn()); // "on"
console.log()
语句将显示在此处。