JavaScript DATAMATRIX PARSER

var arr2d = [['red', 'blue'],['cotton','polyester','silk'],['large','medium','small']]

function combos(list, n = 0, result = [], current = []){
    if (n === list.length) result.push(current)
    else list[n].forEach(item => combos(list, n+1, result, [...current, item]))
 
    return result
}

console.log(combos(arr2d))
 Run code snippet
Calm Chipmunk