Reputation: 1159
var array1 = [column1,column2,column3,column4];
var array2 = [column1 [empid],column2 [mobno],column4 [place]];
array1 = [column3]
then append array1
value with array2
and finallyarray2 = [column1 [empid],column2 [mobno],column3,column4 [place]];
it should be in correct index positionis above case possible?
Upvotes: 0
Views: 71
Reputation: 1551
if you dont want to use any library then you can do
for(elem in array2){
var index = array1.indexOf(array2[elem]);
if(index > -1)
array1.splice(index,1);
}
array2 = array1.concat(array2).sort();
Upvotes: 0
Reputation: 5631
I would recommend using a library like Underscore.js, it has functions like _.union()
that would do what you described. If you don't want to the library you could have a look at their implementation.
Using your example:
array2 = _.union(array1, array2);
Upvotes: 1