Array Methods in JavaScript
Learn the most important array methods in JavaScript with examples. Understand how to use methods like map, filter, reduce, and more to manipulate and manage data effectively.
Learn the most important array methods in JavaScript with examples. Understand how to use methods like map, filter, reduce, and more to manipulate and manage data effectively.
push(): Increases the length of an array by one or more elements and returns the new array length.
pop(): Takes the last element out of an array and gives it back.
shift() moves all ensuing elements to a lower index by removing the initial element from an array and returning it.
unshift(): Increases the length of an array by one or more elements and returns the new array length.
concat() creates a new array by combining two or more arrays without changing the original arrays.
slice(): Without changing the original array, this function takes a portion of an array and returns a new array.
splice(): Modifies an array's contents by inserting new elements in lieu of or deleting old ones.
these are some of them
Different types of Array methods?
1. Manipulation Methods:
push(), pop(),shift(), slice(), etc.
2. Searching and Sorting Methods:
sort(), find(),indexof(), etc.
3. Conversion Methods:
join(), concat(),tostring()
4. Iteration Methods:
foreach(), map(), filter(), etc.
5. Utility Methods:
isArray()
push(): used to add more elements to the end of an array
pop(): used to take out the last elements from an array
shift(): it is used to take out the first element from an array.
unshift(): adding more elements at the beginning of an array.
splice(): add or remove an element from a specific index in an array.
slice(): takes a part of an array and gives you a new array with just that part.