Sumit | Javascript + React
Sumit | Javascript + React

@sumitsaurabh927

9 Tweets 4 reads Mar 02, 2023
There are 40 array methods in Javascript as per MDN
These are the 6 that I use the most:
1. map():
.map() creates a new array with the result of calling a function (that you'll supply) on every item of the array on which it is called.
2. filter():
.filter() as the name suggests is used to filter out some (or all if the criteria is fulfilled) elements out of an array into a new array based on given criteria.
3. reduce():
.reduce() method reduces the array to a single value.
It executes a supplied callback function once for every element of the array and stores the result in something called an accumulator.
This accumulator becomes the final result once all elements are done!
4. concat():
This method concatenates (or joins) two arrays together and returns a new array as the final result.
5. slice():
This method is used to get a copy of a section of an array as the result.
It doesn't modify the original array.
6. splice():
This method is just like the previous method but is a bit more dangerous as it modifies the original array directly.
It is used to add/delete or replace the content of an array.
You can learn more about it here:
Of course there are more methods, but in my experience, these are the ones I've used most frequently.
You can go through this thread for more:
I write threads daily on web dev so if you enjoyed this thread, please:
✅ Follow me @sumitsaurabh927 for more of these.
❤️ Each like, every comment of y'all motivates me to come up with awesome new stuff!
✅ RT the tweet below to show me some love.

Loading suggestions...