It is known how the value, of a key-value pair under an object in the array gets the value of the peer key.

var arr=[
    {
        "name": "bob",
        "age": 20    
    },
    {
        "name": "jane",
        "age": 21
    },
    {
        "name": "joe",
        "age": 22
    }
]

know how name, gets age
is there any other method besides traversal such as map

May.25,2021

use find


let age = arr.forEach(val => {<br> if(val.name=== "bob"){

    return val.age
}

})

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eada2a-2176.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eada2a-2176.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?