Terse way to intersperse element between all elements in JavaScript array?
问题 Say I have an array var arr = [1, 2, 3] , and I want to separate each element by an element eg. var sep = "&" , so the output is [1, "&", 2, "&", 3] . Another way to think about it is I want to do Array.prototype.join ( arr.join(sep) ) without the result being a string (because the elements and separator I am trying to use are Objects, not strings). Is there a functional/nice/elegant way to do this in either es6/7 or lodash without something that feels clunky like: _.flatten(arr.map((el, i) =