Javascript merge two Arrays -


i want merge 2 arrays in javascript this:

['first', 'third', 'fifth', 'seventh', 'ninth'] ['second', 'fourth', 'sixth', 'eigth'] => ['first', 'second', 'third', 'fourth',...] 

also 1 array can have more elements one. example:

['e1', 'e2', 'e3'] ['e4'] => ['e1', 'e4', 'e2', 'e3'] 

what easiest way this?

i don't have in idea how this.

note: have underscorejs available.

with underscore:

var a1 = ['first', 'third', 'fifth', 'seventh', 'ninth']; var a2 = ['second', 'fourth', 'sixth', 'eigth'];  var result = _.compact(_.flatten(_.zip(a1, a2))); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -