Answers for "javascript subset of object array matching certain property"

0

javascript subset of object array matching certain property

let cities = [
    {name: 'Los Angeles', population: 3792621},
    {name: 'New York', population: 8175133},
    {name: 'Chicago', population: 2695598},
    {name: 'Houston', population: 2099451},
    {name: 'Philadelphia', population: 1526006}
];

let bigCities = cities.filter(function (e) {  // filter function
    return e.population > 3000000;
});

//Output:
[
  { name: 'Los Angeles', population: 3792621 },
  { name: 'New York', population: 8175133 }
]
Posted by: Guest on July-02-2020
0

javascript object get subset

const object = { a: 5, b: 6, c: 7  };const subset = (({ a, c }) => ({ a, c }))(object);console.log(subset); // { a: 5, c: 7 }
Posted by: Guest on May-12-2020

Code answers related to "javascript subset of object array matching certain property"

Code answers related to "Javascript"

Browse Popular Code Answers by Language