const obj = [
{ num: 0, name: 'AAA', age: '60'},
{ num: 1, name: 'BBB', age: '20'},
{ num: 2, name: 'CCC', age: '40'},
{ num: 3, name: 'DDD', age: '50'},
];
obj.findIndex(({name}) => name === 'DDD'); // 3
obj.findIndex(({age}) => age === '20'); // 1
const obj = {
key1: 'AAA',
key2: 'BBB',
key3: 'CCC',
key4: 'DDD'
};
var find_value = 'DDD';
const keys = Object.keys(obj);
for (let i=0; i < keys.length; i++) {
let key = keys[i];
let val = obj[key];
if (val == find_value) {
console.log('index = ' + String(i)); // 3
break;
}
}