var arr = [1, 2, 3, 'a', 4, 5, 'b', 9, 'n', 'm'];
arr = arr.reduceRight(function(prev, el, i) {
if (prev.length == 0 ||
(typeof(el) != typeof(prev[0][0]))) {
prev.unshift([el]);
} else {
prev[0].unshift(el);
}
return prev;
}, []);
console.log(JSON.stringify(arr));
[[1,2,3],["a"],[4,5],["b"],[9],["n","m"]]