Use Array.find
:
let array = [
{ id: 1, value: "itemname" },
{ id: 2, value: "itemname" }
];
let item1 = array.find(i => i.id === 1);
Array.find at MDN: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Related Contents:
- How do I check whether an array contains a string in TypeScript?
- How can I loop through enum values for display in radio buttons? [duplicate]
- TypeScript: Creating an empty typed container array
- How can I use optional chaining with arrays and functions?
- TypeScript enum to object array
- Declare an array in TypeScript
- spread operator vs array.concat()
- Angular2 component’s “this” is undefined when executing callback function
- How to sort object array based on key in typescript [duplicate]
- Why is using “for…in” for array iteration a bad idea?
- How do I check if a variable is an array in JavaScript?
- Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’
- Most efficient method to groupby on an array of objects
- Selecting last element in JavaScript array [duplicate]
- How does `Array.prototype.slice.call` work?
- How to load external scripts dynamically in Angular?
- Angular4 – No value accessor for form control
- Convert base64 string to ArrayBuffer
- remove first element from array and return the array minus the first element
- Unpacking array into separate variables in JavaScript
- In Typescript, what is the difference between type and interface?
- How to import js-modules into TypeScript file?
- Append an array to another array in JavaScript [duplicate]
- Set window.location with TypeScript
- What is `export type` in Typescript?
- MongoDB select where in array of _id?
- Uncaught TypeError: Object.values is not a function JavaScript
- Sorting arrays numerically by object property value
- import * as React from ‘react’; vs import React from ‘react’;
- Using styled-components with props and TypeScript
- Fastest JavaScript summation
- JavaScript split String with white space
- Time complexity of unshift() vs. push() in Javascript
- How to store a byte array in Javascript
- Cloning an object in JavaScript
- javascript – match string against the array of regular expressions
- What is the most efficient way to reverse an array in Javascript?
- RegEx to match stuff between parentheses
- React – using TypeScript vs Flow vs?
- Filter null from an array in JavaScript
- Adding TypeScript to existing create-react-app app
- Applying a function to each object in a JavaScript array
- The best way to remove array element by value
- How to flatten array in jQuery?
- Why does javascript’s “in” operator return true when testing if 0 exists in an array that doesn’t contain 0?
- Change size of mat-icon-button
- Typescript interface optional properties depending on other property
- How to stub a Typescript-Interface / Type-definition?
- Filter array to have unique values [duplicate]
- Compute intersection of two arrays in JavaScript [duplicate]