Join multiple arrays of order indexes

Using javascript, I have multiple arrays of indexes, representing an order:
[[0,1,2], [2,0,1], [1,2,0], [0,1,2], ...]
I need to join to a single sequential array keeping the order of the input. This would be the output of the input above:
[0,1,2,5,3,4,7,8,6,9,10,11, ...]
Thanks.


Source: stackoverflow-javascript