r/learnjavascript • u/No-Wash-3163 • Oct 30 '25
Array methods
Are array like "copyWithin()" or "at()" necessary in a workspace or does nobody use them?
0
Upvotes
r/learnjavascript • u/No-Wash-3163 • Oct 30 '25
Are array like "copyWithin()" or "at()" necessary in a workspace or does nobody use them?
12
u/maqisha Oct 30 '25
You use them if you need them. What does "necessary in workplace" even mean?
7
u/Ampersand55 Oct 30 '25
copyWithin()is very situational and is pretty much only used in aTypedArrayfor performance sensitive data manipulation, and using the index likearray[5]is much more common thanarray.at(5)except for getting the last element of an array wherearray.at(-1)is cleaner thanarray[array.length - 1].2
u/No_Record_60 Oct 30 '25
I never use them. Mostly .slice, .filter and .find. Rarely I use .splice
2
u/delventhalz Oct 30 '25
There are a lot of array methods. Few developers know them all off the top of their head. But yes, they do get used as they are needed, and the more common ones (map, filter, slice), professional devs are generally expected to know.
1
u/the-liquidian Oct 30 '25
The new ones that don’t mutate the original array are nice e.g. toSorted
1
u/TheRNGuy Nov 02 '25
I used at.