例如1234 2345 得234
数组求差集
const deleteRepeat = (beforeCity, newCity) => {
var arrBeforeCity = [];
var arrNewCity = [];
beforeCity.map((v, i) => {
arrBeforeCity.push(v.cityCode);
});
newCity.map((v, i) => {
arrNewCity.push(v.cityCode);
});
var allDeletecity = deleteCity(arrBeforeCity, arrNewCity);
return allDeletecity;
};
例如1234 2345 得1
数组压成字典
const arrChangeDic = (arr1, arr2) => {
var map1 = new Map();
arr1.map((item, i) => {
map1.set(item.cityCode, item);
});
arr2.map((item, i) => {
if (map1.has(item.cityCode)) {
map1.delete(item.cityCode);
}
});
var cityCode = [];
//取出citycode
for (let key of map1.keys()) {
cityCode.push(key);
}
return cityCode;
};