Answer the question
In order to leave comments, you need to log in
Remove elements from an array in javascript?
Good afternoon!
There are two arrays. The first is [1,2,3] and the second is [{id:1},{id:2},{id:3},{id:4},{id:5}]. I need to get the third array [{id:4},{id:5}], that is, how to remove from the second array elements with id equal to the values of the elements of the first array?
Answer the question
In order to leave comments, you need to log in
var f = [1,2,3]; var ff = [{id:1},{id:2},{id:3},{id:4},{id:5}]
ff.filter(function (el) { return ~f.indexOf(el.id) })
var mass = [{id:1},{id:2},{id:3},{id:4},{id:5}].map(function(){
//И ПАНЕСЛАСЬ
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question