merging array in javascript -


this question has answer here:

is there way merge following array :

var arr = [["2014-2-5", "2014-2-4", "2014-1-9", "2014-1-8"], [], ["2014-2-4"], [], []] 

and make :

["2014-2-5", "2014-2-4", "2014-1-9", "2014-1-8", "2014-2-4"] 

i tried console.log($.merge(arr )); not working.

thanks

use array's reduce in combination concat:

arr.reduce(function(previousvalue, currentvalue, index, array){   return previousvalue.concat(currentvalue); }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -