I have an array [a, b, c]. I want to be able to insert a value between each elements of this array like that: [0, a, 0, b, 0, c, 0].
[a, b, c]
[0, a, 0, b, 0, c, 0]
I gues
You can use map() with ES6 spread syntax and concat()
map()
concat()
var arr = ['a', 'b', 'c'] var newArr = [0].concat(...arr.map(e => [e, 0])) console.log(newArr)