My intention is to split an array using a separator and choose a limit of its splitting.
var arr = [89, 'sdf', 0, null, 0, true, 89, 0, 'sdf'];
var res = [];
while (arr.length) {
res.push(arr.splice(0, 2));
}
console.log(res)
For example: If 0 is the separator and 2 is the limit
arr.split(0, 2)
[[89, 'sdf'], [null]] //output
nullbut remove0?[[89, "sdf"], [0, true]]?