The basic method for merging arrays in JavaScript is described.
Here are two simple methods:
First
var mergeTo = [4,5,6], mergeFrom = [7,8,9]; mergeTo = mergeTo.concat(mergeFrom); mergeTo; // is: [4, 5, 6, 7, 8, 9]
Or
var a = [1,2], b = [3,4], c = a.concat(b);
Second
var mergeTo = [4,5,6], var mergeFrom = [7,8,9]; Array.prototype.push.apply(mergeTo, mergeFrom); mergeTo; // is: [4, 5, 6, 7, 8, 9]
Merge multiple arrays merge array:
// Special processing service-you must enable var _ SPECIAL_MUST_ENABLE_LIST = ['intime']; if (termNo! = Null & termNo. indexOf ("9966") = 0) {var newMustEnableList = ['mobile', 'psp ', 'jtk', 'credentials', 'train', 'bank ', 'alipay', 'lottery', 'movi', 'littletransfer', 'trafficfines', 'certificate', 'mall', 'airplane ', 'Hotel ', 'recycle']; _ SPECIAL_MUST_ENABLE_LIST = _ SPECIAL_MUST_ENABLE_LIST.concat (newMustEnableList );}
Articles you may be interested in:
- JavaScript simulated array merging concat
- JS implements the method of merging two arrays and removing duplicate items and leaving only one
- Difference between JS array merge push and concat
- Examples of array merging and sorting in JavaScript
- JavaScript merge two arrays and remove repeated items
- Examples of merging multiple arrays using native JavaScript
- Comparison of several methods and advantages of JS array Merging
- Use different methods to combine/merge two JS Arrays
- N methods for merging arrays in JavaScript
- JavaScript and jquey Merge multiple arrays