Javascript 基于其他数组的过滤器数组

Javascript 基于其他数组的过滤器数组,javascript,arrays,filter,Javascript,Arrays,Filter,我有两个不同URL的数组,可能在相同的图像上 const images1 = [ "https://somelink222/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg", "https://somelink222/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg" ] // denne skal filtreres const images2 = [ {lo

我有两个不同URL的数组,可能在相同的图像上

const images1 = [
  "https://somelink222/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg",
  "https://somelink222/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg"
]

// denne skal filtreres
const images2 = [
  {location: "https://otherLink1/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg"},
  {location: "https://otherLink1/01ao00/f2cdeaf286a7636c8b3010e34acae475.jpeg"},
  {location: "https://otherLink1/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg"}
]
我想过滤图像2,这样如果图像1中包含任何文件名,例如“01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg”,只需

const images1=
[ "https://somelink222/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg"
, "https://somelink222/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg"
] 
常量图像2=
[{地点:https://otherLink1/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg"} 
,{位置:https://otherLink1/01ao00/f2cdeaf286a7636c8b3010e34acae475.jpeg"} 
,{位置:https://otherLink1/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg"} 
] 
const result=images2.filter(el=>
{
设img=el.location.split('/').pop()
返回图像1.some(x=>x.includes(img))
})
console.log(结果)

。作为控制台包装{max height:100%!important;top:0}
查看。请阅读“不要问……你没有试图找到答案的问题(展示你的作品!)”@psdpainter你误判了他的问题question@MisterJojo你能解释一下吗?我只看到免费编码服务的任务转储/问题,没有任何努力。你看到更多了吗?“不要问……你还没有试图找到答案的问题(展示你的工作!)”在这种情况下很明显。@jabaa你很严厉!这个问题比直接使用array.filter方法要微妙一些;如果不认为这是对免费代码的请求,那么您只需要对阵列上的可能性有很好的了解。这是一个学习酷的问题。我看得出我很接近。我今天晚些时候会试一试
const images1 = [
    'https://somelink222/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg',
    'https://somelink222/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg',
];

// denne skal filtreres
const images2 = [
    { location: 'https://otherLink1/01ao00/5363c2ba39696bd76d6dd1a25ab49609.jpeg' },
    { location: 'https://otherLink1/01ao00/f2cdeaf286a7636c8b3010e34acae475.jpeg' },
    { location: 'https://otherLink1/01ao00/b8d695c4ea5f1c141e5d54b4c50bcd78.jpeg' },
];

const img1_reduce_data = images1.map(val => val.split('/').pop());
const res = images2.filter(val => img1_reduce_data.includes(val.location.split('/').pop()));
console.log(res);