Get the App
SLTechnology News&Howtos  ›  Development  › 

How to abbreviate Array.find for JavaScript

Shulou Source: shulou.com Published: 2022-06-01 04:38:41 10月04日 Update

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!

Tags: Abbreviations articles content functions loops ordinary not so much most arrays more knowledge industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Shulou Tech Info Linux Shulou Information