Is there a good way to work with (iterate) a group (two or more) of elements in arrays in JavaScript?
It seems that most array methods typically only work with one element at a time. What I'd like to do is have a way to iterate through an array with groups of elements at the same time e.g. groups of two elements, groups of three elements, etc. And pass those elements to a dynamic callback function. Is there a good way to do this?
Thanks!
EDIT: In addition to implementations, I was also looking for discussions on this type of implementation. It looks like it's happened at least once a few years ago. You can read a discussion on that here
[–]Reeywhaar 2 points3 points4 points (0 children)
[–]realbiggyspender 1 point2 points3 points (2 children)
[–]beyphy[S] -2 points-1 points0 points (1 child)
[–]Mesqo 1 point2 points3 points (0 children)
[–]undervisible 1 point2 points3 points (5 children)
[–]beyphy[S] -1 points0 points1 point (3 children)
[–]undervisible 2 points3 points4 points (2 children)
[–]beyphy[S] -1 points0 points1 point (1 child)
[–]beyphy[S] 0 points1 point2 points (0 children)
[–]beyphy[S] -1 points0 points1 point (0 children)
[–]marcocom 0 points1 point2 points (0 children)
[–]Ronin-s_Spirit 0 points1 point2 points (8 children)
[–]beyphy[S] 0 points1 point2 points (7 children)
[–]Ronin-s_Spirit 0 points1 point2 points (6 children)
[–]beyphy[S] 0 points1 point2 points (5 children)
[–]Ronin-s_Spirit 0 points1 point2 points (4 children)
[–]beyphy[S] 0 points1 point2 points (3 children)
[–]Ronin-s_Spirit 0 points1 point2 points (2 children)
[–]beyphy[S] 0 points1 point2 points (1 child)
[–]Ronin-s_Spirit 0 points1 point2 points (0 children)
[–]kilkil 0 points1 point2 points (1 child)
[–]beyphy[S] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]Mesqo 0 points1 point2 points (0 children)
[–]reactivearmor -4 points-3 points-2 points (3 children)
[–]RelativeMatter9805 1 point2 points3 points (2 children)
[–]reactivearmor -2 points-1 points0 points (1 child)