i want to split an array into a list of subarray by a/or more given seperator/s.
something like this:
var myArray = [null, 5, 'whazzup?', object, '15', 34.6];
var mySeperators = [null, '15'];
splitArray(myArray, mySeperators)
should result in that:
[[], [5, 'whazzup?', object], [34.6]]
the source array can contain the seperators multiple times. how to accomplish this?
when it makes solution easier, i’m using mootools as base library.
Given ECMAScript 5, it is possible to accomplish this with the use of
Array#reduce:I have no experience with MooTools; however, it appears to polyfill
Array#reduce, if backwards-compatibility is required.