This is exactly what I mean but in Javascript: PHP remove empty items from sides of an array
I'm looking around the cleanest way to do it. I wondering if there is a better way than loop the array manually.
Here an example:
const fullArray = new Array(10);
fullArray[3] = 1;
fullArray[5] = 1;
fullArray[7] = 1;
console.log('Input:', fullArray);
const trimedArray = new Array(4);
trimedArray[0] = 1;
trimedArray[2] = 1;
trimedArray[4] = 1;
console.log('Output:', trimedArray);