Skip to content

Instantly share code, notes, and snippets.

@learnwell
Created March 2, 2019 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save learnwell/821f788079ff97416955ad3051c620c9 to your computer and use it in GitHub Desktop.
Save learnwell/821f788079ff97416955ad3051c620c9 to your computer and use it in GitHub Desktop.
Use filter() method to check if an array of object includes what we seek

GOAL

Use filter() method to check if an array of object includes what we seek via TypeScript Sandbox online: https://typescript-play.js.org/#code/Q

// testing how the out-of-box `filter` for ES6 ecma works without utilities like lodash
// https://typescript-play.js.org/#code/Q
let knownFiles = [
    { file: 'xxx', status: 0 },
    { file: 'yyy', status: 1 }
];

let file='yyy';
console.log(
    knownFiles.filter(row => (row.file === file))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment