Skip to content

Commit 2f9f5a5

Browse files
committed
Array mutation methods
1 parent a5cf154 commit 2f9f5a5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -8920,6 +8920,24 @@ The `globalThis` property provides a standard way of accessing the global object
89208920
```
89218921
**[⬆ Back to Top](#table-of-contents)**
89228922
8923+
469. ### What are the array mutation methods?
8924+
JavaScript array methods can be categorized into two groups:
8925+
1. Mutating methods: These are the methods that directly modify the original array.
8926+
2. Non-mutating methods: These methods return a new array without altering the original one.
8927+
8928+
There are 9 methods in total that mutate the arrays,
8929+
1. **push:** Adds one or more elements to the end of the array and returns the new length.
8930+
2. **pop:** Removes the last element from the array and returns that element.
8931+
3. **unshift:** Adds one or more elements to the beginning of the array and returns the new length..
8932+
4. **shift:** Removes the first element from the array and returns that element.
8933+
5. **splice:** Adds or removes elements from the array at a specific index position.
8934+
6. **sort:** Sorts the elements of the array in-place based on a given sorting criteria.
8935+
7. **reverse:** Reverses the order of elements in the given array.
8936+
8. **fill:** Fills all elements of the array with a specific value.
8937+
9. **copyWithIn:** Copies a sequence of elements within the array to a specified target index in the same array.
8938+
8939+
**[⬆ Back to Top](#table-of-contents)**
8940+
89238941
<!-- QUESTIONS_END -->
89248942
89258943
### Coding Exercise

0 commit comments

Comments
 (0)