Is This the Most Useful JavaScript Method?
Вставка
- Опубліковано 19 січ 2025
- Methods such as map(), filter(), every() & reduce() are useful, but which one would you choose if you couldn't use one of the other 3 again? Let's find out.
For your reference, check this out:
developer.mozi...
🏫 My Udemy Courses - www.udemy.com/...
🎨 Download my VS Code theme - marketplace.vi...
💜 Join my Discord Server - / discord
🐦 Find me on Twitter - / dcodeyt
💸 Support me on Patreon - / dcode
📰 Follow me on DEV Community - dev.to/dcodeyt
📹 Join this channel to get access to perks - / @dcode-software
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
Absolutely!!! Reduce() ! You can do same jobs if you know how to!
- but
the performance results for processing an array of 100,000 elements:
• map() took approximately 0.044 seconds
• reduce() took approximately 19.010 seconds
not true, write your code so we can test it
A whooping 19 secs? That's absolute madness
Nice one! Thanks!
I don't think result && ... will reassign the value to result, or am I mistaking the prev result is the value of the previous return value?
it will
Yeah it works because once it reaches the first element that gives "false", the value can't ever evaluate to "true" ever again because we use &&
I knew of it for few years, and basically never used it, but I think I will start now... I guess I'll first use it to translate other methods to reduce, just to get used to it...
Yeah sure, but of course, I'm not suggesting you replace "map" with "reduce". If the method exists for the purpose then definitely use it. This video is more for education
Good examples, thanks for this
All good 👍
reduce() is the god method
💪
Beautiful.... 👌👌👌👌👌👏👏👏👏🙏🙏🙏🙏🌹🌹🌹🌹🌹🖖🖖🖖🖖🖖🖖
Many many thanks