How does javascript cross merge two arrays?

how does javascript cross merge two arrays?
for example, there are two arrays, the first array has 12 elements, and the second array has 3 elements:

array_foo=["1","2","3","4","5","6","7","8","9","10","11","12"];
array_bar=["a","b","c"];

I want to insert the an element of the second array after 4 of the first array, b element after 8 of the first array, and c element after 12 of the first array. The result is as follows:

array_result=["1","2","3","4","a","5","6","7","8","b","9","10","11","12","c"];

what should I do?

Mar.16,2021

@ AnthonyYY
the slice upstairs can be further optimized:

array_bar.forEach((item, index) => {
    return array_foo.splice(4 * (index + 1) + index, 0, item);
});

thanks for the hint of @ original sin, the author can adopt his answer

Menu