I have two arrays. The first array contains some values while the second array contains some elements which should be inserted to the first array. For example:
var aArr = [ {'a':111}, {'b':222}, {'c':333} ... ]
var bArr = [ {'x': 0}, {'y': 0} ] // I'm not sure it's length
// finail I need got something like
var aArr = [{'x': 0}, {'y': 0}, {'c':333} ...]
and bArr array is not sure it's length ,maybe it has one element
var aArr = [ {'a':111}, {'b':222}, {'c':333} ... ]
var bArr = [ {'x': 0} ]
// finail I need got something like
var aArr = [{'x': 0}, {'b': 222}, {'c':333} ...]
I use splice() which not work very well
var a = [1, 2, 3],
b = [4, 5];
function prependArray(a, b) {
a.splice(0, b.length, b);
return a;
}
var result = prependArray(a, b);
// result = [[4, 5], 3] not [ 4, 5, 3]
What should I do? ? I need more efficient method, because the aArr have more than 3000 values, and bArr have more than 100 values.
thanks.

a = b.concat(a);? Or, if you can use ES 5, thena.splice(0, 0, ...b);?a.splice(0, b.length, ...b)should do it.