Skip to content
Advertisement

Create object from another one using filter function

I’m trying to create an array of objects using an array of objects. My first array is like that : enter image description here

And I want to create an object list with only an id, a name and a task. This is what i do actually, but it doesn’t work :

JavaScript

The ListModel object is :

JavaScript

Advertisement

Answer

The filter() function is more-so utilized for returning an array based upon some search criteria, similar to a WHERE clause. What you want is to utilize is the map() function using something like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement