Home >Web Front-end >JS Tutorial >Native JavaScript implementation of merging multiple arrays example_javascript skills

Native JavaScript implementation of merging multiple arrays example_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:35:50956browse

1. Native JavaScript implementation

Copy code The code is as follows:

var array1 = ["a", "b"];
var array2 = ["c", "d"];

After merging, I want it to look like this:

Copy code The code is as follows:

var array= [ "a", "b", "c", < ;span class="string" style="color:rgb(221,17,68)">"d"];

Can be used

Copy code The code is as follows:

arr1.concat(arr2);


2. Jquery implementation

Copy code The code is as follows:

$.merge(array1,array2);
console.log($.unique(array1));
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn