I have an object
var arr = {
alfa: {
name: "a",
id: "1"
},
beta: {
name: "b",
id: "2"
}}
I want to log title of second prop 'beta'
I cant to find prop values with 'find'
Object.values(arr).find(obj => {
return obj.id === '2'
})
but how I can to extract prop name
in log I want to print like this:
console.log('second prop name is ', extractPropNameById(2))
and result must to be like:
"second prop name is beta"
Object.keys(arr)
return only array of props ["alfa", "beta"]
and find by id returns undefinded
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…