The Smartest Way to Search Arrays in JavaScript

preview_player
Показать описание
In today's video, we have a look at different ways to search arrays in JavaScript - things such as includes(), find() and findIndex() can be used to do this 😎

For your reference, check this out:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

#dcode #javascript
Рекомендации по теме
Комментарии
Автор

Great video 😎 Already personally familiar with all those approaches.

There is also an alternate version of searching an array and returning a boolean to indicate whether an even number exists in this example, using the Array.prototype.some() function.

The Array.prototype.some() function will traverse through the array until the expression evaluates to find a match and returns true, or false if the expression doesn't ever evaluate / match, thereby returning false. Powerful, yet can be performant, as it can break out of an array iteration on first match, without traversing through the whole array.

See an example snippet below:

```
const numbers = [5, 9, 2, 4, 3];
const containsEvenNumber = numbers.some(n => n % 2 === 0);

// true
```

Sayvai
Автор

So many ways to skin the poverbial cat. Thanks for the great content. By any chance are you willing to do tutorials on making packages

raphaeljaggerd
Автор

Hi Domenic,

Thanks for your very helpful videos; I am going through them one by one. I was wondering if you also have videos on React. I did a quick search, but I didn't find any.

Thanks,
Faraz

farazk
Автор

Great video. Array.prototype.some would’ve been perfect to introduce after the Array.prototype.find example, since it is similar but returns the Boolean like wanted.

UsernameUsername
Автор

hi! i finished js course since days ago... I don't know what should do to practice?
Solve some Problems In Problem Solving Websites Or start directly build project with HTML, CSS and JS?
would you please make a video show how to build a begginer/intermediate website and landing page 🙏 🙏 with Front-End Basics🙏 🙏
Thank You ♥ ♥

lounesb
Автор

You're gorgeous 🔥 I liks Your Videos 📹 Keep going🏃

lounesb