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
| 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 value1 = employee.find(callback) console.log(value1)
const value2 = employee.find(function(element){ return element.department === 'MIS' }) console.log(value2)
const value3 = employee.find(element => element.name === 'Bill') console.log(value3)
|