Beautiful! findIndex() is super powerful.

💛 JavaScript tip 💛 indexOf uses strict equality comparison under the hood. This means it can only ever find the exact reference but not an identical object. 'findIndex' fixes this because you can pass a callback you can use to identify an object. ↓

oliverjumpertz's tweet image. 💛 JavaScript tip 💛

indexOf uses strict equality comparison under the hood. 

This means it can only ever find the exact reference but not an identical object.

'findIndex' fixes this because you can pass a callback you can use to identify an object. ↓


Another powerful use of findIndex(): const a = [2, 8, 73 /*,…*/]; const s = 55; if (1 + findIndex(x=>x==s)) { console.log("a contains s"); };


1st Dr.V.Chandrasekar BCA., MCA., Mphil/ Phd Computer Sciences ., Pursuing., Computer Subject:Java and Javascript Program . (100/100).Programmer., Software Engineer. Cell number:9360949895. E-mail:[email protected] 🙂 Freelaunzer 🇮🇳🥘🍲.


United States Tendenze
Loading...

Something went wrong.


Something went wrong.