Chris Staudinger
Chris Staudinger

@ChrisStaud

6 تغريدة 3 قراءة Oct 13, 2022
Not enough Developers know these JavaScript programming tips.
reduce(), some(), and every() can make your code cleaner and easier to read, here's how they work:
1.
1a) JavaScript reduce() method is explained in a complex way IMO by MDN & other docs — here’s my simpler definition.
reduce() runs a calculation on every element of an array & passes the result of previous iterations. It returns the result once all elements have been processed.
1b) If you want to dig deep into the JavaScript reduce() method, MDN docs is a good resource.
Hopefully, my illustration made it a lot easier to understand than the long complicated docs 😅
👉 developer.mozilla.org
2. JavaScript some() method
some() method loops through an array and checks a condition against each element.
It exits early and returns true once it finds an element that passes the condition implemented by the provided callback function.
Otherwise, it returns false.
3. JavaScript every() method
Loops through an array and checks that every element meets the condition implemented by the provided callback function.
It returns true if all elements meet the condition, otherwise false.
That's the end of this thread.
I simplify software development and getting into tech💡
Follow @ChrisStaud for more free tips and free resources.
If you enjoyed this thread, don't forget to like, comment, and retweet the first tweet.

جاري تحميل الاقتراحات...