How to separate array into 4 columns and pass to each column 10 items from array?

Lets say there is an dynamic array containing 40 elements (array doesn’t change over time, but changes on every render). What I want to do is, loop through this array and return 4 elements, each containing 10 li elements (which are objects from my array), where none object from array is repeated. How to achieve that with JavaScript ?

I wanted to style objects from array with one parent flex container, containing 4 div elements with flex: 25%, and li elements being children of that 4 divs. Like in this example: w3c.
But my images are not static so I can’t define each element with typing