1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| const employee = [ {name:'Amy',department:'AD', phone:1000}, {name:'Betty',department:'IT', phone:1200}, {name:'Mary',department:'PM', phone:1300}, {name:'Susan',department:'MIS', phone:1400}, {name:'Bill',department:'MIS', phone:1405}, ]
function callback(element){ return element.phone === 1200 }
const index1 = employee.findIndex(callback) console.log(index1)
const index2 = employee.findIndex(function(element){ return element.department === 'MIS' }) console.log(index2)
const index3 = employee.findIndex(element => element.name === 'Bill') console.log(index3)
|