Javascript obtains the data of multi-dimensional array through one-dimensional array.

:
arr1:
var arr1 =[1,2,3,4,5]  var arr1 =[1,4]; //1,2,3...ID

arr2:
var arr2=[{id:1,name:11},{id:2,name:222},{id:3,name:333},{id:4,name:444}];

:

arr1:[1,2],arr2[{id:1,name:11},{id:2,name:222}];
arr1:[1,3],arr2[{id:1,name:11},{id:3,name:333}];



Apr.09,2021

var arr2 = arr1.map((item,index)=>{
    return {
        id:item,
        name:+new Array(3).fill(item).join('')
    }
})
< hr >

did not understand the question at first

var arr3 = Object.create(null)
arr2.forEach(item=>{
    arr3[ item.id ] = item
})
var arr4 = arr.map(item=>{
    return arr3[ item ]
})


arr1.forEach(el => {

console.log( arr2.filter(item => item.id == el)

})

the desired result is directly assigned. I printed it out for you here

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ed8e-2b18b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ed8e-2b18b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?