标签:=== filter tps == function 语法 free cti 定义
1.要求
2.思路
3.代码
function diff(arr1, arr2) {
var newArr = [];
newArr = arr1.concat(arr2);
function check(item){
if(arr1.indexOf(item) === -1 ||arr2.indexOf(item) === -1){
return item;
}
}
return newArr.filter(check);
}
diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
4.相关链接
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
5.博客说明:以后的博客均采用mardown语法编写
Diff Two Arrays-freecodecamp算法题目
标签:=== filter tps == function 语法 free cti 定义
原文地址:https://www.cnblogs.com/ahswch/p/9297849.html