$.array.select
Select method of array helpers
You may want to select some field from array of objects by its property name, to do this just select some of object properties from array of objects and see the result, this why we provide select method. By using this method, we can choose the properties we want to display on our new array.
$.array.select(fromArray, ...propertyNames*)
// Example:
const fromArray = [
{ id: 1, name: 'Zulkifli', position: 'Vue.js Developer', office: 'Jakarta', extension: 2456, startdate: '2011-10-11', salary: 160000 },
{ id: 2, name: 'Usman', position: 'Alpine.js Developer', office: 'Banda Aceh', extension: 2466, startdate: '2011-10-11', salary: 270000 },
{ id: 3, name: 'Nurjannah', position: 'Alga.js Developer', office: 'Sigli', extension: 2474, startdate: '2011-10-11', salary: 150000 }
]
$.array.select(fromArray, 'name', 'office')
//=> [
// {name: 'Zulkifli', office: 'Jakarta'},
// {name: 'Usman', office: 'Banda Aceh'},
// {name: 'Nurjannah', office: 'Sigli'}
//]
Last updated
Was this helpful?