Lodash _.cycle() Method
The _.cycle() method is then used to build a new array containing the given number of iterations of the given array, that are strung end-to-end. Thus, the new array created contains the given array number of given times.
_.cycle( integer, array )
Parameters: This method takes two parameters as shown above and discussed below:
- integer: It is a number that specifies the number of times the given array is iterated.
- array: It is an array that is iterated through to make the new array.
Return Value: This method returns a new cycled array.
Cycled array : [ 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 ]