We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var a=[1,2,3], b=[4,5,6]; var c=a.concat(b); console.log(c);// 1,2,3,4,5,6 console.log(a);// 1,2,3 不改变本身
合并数组 arr1 和数组 arr2 ,使用 Array.prototype.push.apply(arr1,arr2) or arr1.push.apply(arr1,arr2);
arr1
arr2
Array.prototype.push.apply(arr1,arr2) or arr1.push.apply(arr1,arr2);
var arr1=['a','b']; var arr2=['c','d','e']; Array.prototype.push.apply(arr1,arr2); //或者 arr1.push.apply(arr1,arr2); console.log(arr1) //['a','b','c','d','e']
var arr1=['a','b']; var arr2=['c','d','e']; for(var i=0;i<arr2.length;i++){ arr1.push(arr2[i]) } console.log(arr1);//['a','b','c','d','e']
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1. concat 方法
2. apply 方法
合并数组
arr1
和数组arr2
,使用Array.prototype.push.apply(arr1,arr2) or arr1.push.apply(arr1,arr2);
3. 循环遍历
The text was updated successfully, but these errors were encountered: