There is no function in the library which does what you expect. But if you approach it simply, you can use the next approach
var a = [1, 2, 3, null, 2, null, 4]
var result = [], temp = [];
for(var i = 0; i < a.length; i++) {
if (a[i] === null) {
if (temp.length == 0) continue;
result.push(temp);
temp = [];
}
else {
temp.push(a[i]);
}
}
if (temp.length != 0) result.push(temp);
// use your result, it gives [[1, 2, 3], [2], [4]]
i have added some functionalities to prevent problems with double null, starting null and ending null. The next step is just wrapping the above snippet in a function, using a as argument and result as return value. This even handles a = [] without problems too.