function interpose(x,xs){ var r = []; var len = xs.length; for(var i=0; i<len; i++){ r.push(xs[i]); r.push(x); } r.pop(); return r; } interpose('x',[1,2,3,4]); //=> [ 1, "x", 2, "x", 3, "x", 4 ]