How to abbreviate Array.find for JavaScript
Editor to share with you how to abbreviate JavaScript Array.find, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Array.find
If you have ever written a find function in a normal JavaScript, you may have used a for loop. In ES6, a new array function called find () is introduced, which can implement the abbreviation of for loop.
Const pets = [{type: 'Dog', name:' Max'}, {type: 'Cat', name:' Karl'}, {type: 'Dog', name:' Tommy'},] function findDog (name) {for (let I = 0; I pet.type = 'Dog' & & pet.name =' Tommy'); console.log (pet) / / {type: 'Dog', name:' Tommy'} these are all the contents of the article "how to abbreviate Array.find for JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!