// Supported in IE 9-11 const people = [ {id: 1, name: 'John'}, {id: 2, name: 'Adam'}, ]; const isFound = people.some(element => { if (element.id === 1) { return true; } return false; }); console.log(isFound); // 👉️ true if (isFound) { // object is contained in array }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter