var arr = [ [1,2], [4,5], [7,8] ]; var sarr = [[]]; for (var i = 0; i < arr.length; i++) { var tarr = []; for (var j = 0; j < sarr.length; j++) for (var k = 0; k < arr[i].length; k++){ tarr.push(sarr[j].concat(arr[i][k])); } sarr = tarr; } console.log(sarr)