Answers for "if i have an array of objects, how do i call each object?"

62

find an object in an array of objects javascript

let arr = [
    { name:"string 1", value:"this", other: "that" },
    { name:"string 2", value:"this", other: "that" }
];

let obj = arr.find(o => o.name === 'string 1');

console.log(obj);
Posted by: Guest on May-08-2020
0

array of objects for in

const mobiles = [
    {
        brand: 'Samsung',
        model: 'Galaxy Note 9'
    },
    {
        brand: 'Google',
        model: 'Pixel 3'
    },
    {
        brand: 'Apple',
        model: 'iPhone X'
    }
];

mobiles.forEach(mobile => {
    for (let key in mobile) {
        console.log(`${key}: ${mobile[key]}`);
    }
});
Posted by: Guest on December-27-2021

Code answers related to "if i have an array of objects, how do i call each object?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language