javascript filter array of objects by id
const myArray = [{id: 1, name:'pipi'}, {id: 2, name:'popo'}];
const id = 2;
const variableOne = myArray.filter(itemInArray => itemInArray.id === id);
console.log(cariableOne[0].name);
javascript filter array of objects by id
const myArray = [{id: 1, name:'pipi'}, {id: 2, name:'popo'}];
const id = 2;
const variableOne = myArray.filter(itemInArray => itemInArray.id === id);
console.log(cariableOne[0].name);
how to find id in array javascript
//The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
const array1 = [5, 12, 8, 130, 44];
const found = array1.find(element => element > 10);
console.log(found);
// expected output: 12
javascript array filter
var numbers = [1, 3, 6, 8, 11];
var lucky = numbers.filter(function(number) {
return number > 7;
});
// [ 8, 11 ]
filter in js
const filterThisArray = ["a","b","c","d","e"]
console.log(filterThisArray) // Array(5) [ "a","b","c","d","e" ]
const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray) // Array(4) [ "a","b","c","d" ]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us