Array 'find' method in JavaScript (Array.prototype.find) - JavaScript Tutorial For Beginners

preview_player
Показать описание
The find() method in Javascript is used on arrays to find the first element in the array that meets a condition which you pass in through a function.

In this video, we look at how we can retrieve an object from an Array based on it's property value of 'occupation'.

For your reference:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

Thank you for a clear and concise explanation!

MrPDTaylor
Автор

Please don't stop uploading videos. Great work. Audio quality is also good. :)

SabbirAhmed-gubk
Автор

I just spent maybe 3 hours trying to do this as prescribed by my teacher, and still couldn't figure it out - teacher insists on callback functions with functions to find a match in an array, made no sense to me whatsoever, maybe 12 lines of code for the same result as this. Finally got it working in 30 seconds with this. Thanks.

YKillerSPOOBLY
Автор

thank you ... but what if you have three objects with the occupation dentist and you want to find the name of the one in the middle ?

samialaa
Автор

so how would you code if you wanted ALL dentist?

vincecaruso
Автор

This is somewhat helpful, but rarely would you be able to "hard code" the condition that you are searching for, "dentist" in your case. How would you pass in, BOTH the array that you are searching and the value, or condition that you are searching for?

Shakespeare
Автор

What kind of keyboard do you use? It sounds amazing lol

Justenphelps
Автор

what happens if we have occupation as an object again with two key value pairs...in such case..how do we use find???

vallinaidu
Автор

please i dont understand why u passed in person as an argument when you run the code does person become people in the global function

frownless
Автор

const personas = [
{nombre: 'Dom', ocupacion: 'Desarrollador'},
{nombre: 'Eric', ocupacion: 'Dentista'},
{nombre: 'Kate', ocupacion: 'Peluquera'}
];

const people = [
{name: 'Dom', ocupation: 'Software developer'},
{name: 'Eric', ocupation: 'Dentist'},
{name: 'Kate', ocupation: 'Hair dresser'}
];

bigbox