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.
this method not change existing arrays, instead returns new array.
you need assign operation a
a = a.concat(b)
Comments
Post a Comment