Javascript: how to join two arrays -


this question has answer here:

i know has been asked lot of times, cannot work.

i have empty array a

var = []; 

and array object b

var b = [{    title: 'test' }] 

i want join them a b. idea inside for loop a added new item each time.

by using a.concat(b), a results in empty array.

not sure missing.

per array.prototype.concat()

this method not change existing arrays, instead returns new array.

you need assign operation a

a = a.concat(b)


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -