Push () :
You can add one or more elements to the end of an array and return a new length.
var fruits = ["Banana", "Orange", "Apple", "Mango"]; \ fruits.push("Kiwi")Copy the code
Output: Banana, Orange, Apple, Mango, Kiwi
Add elements at the beginning of the array: unshift ()
Pop () :
The delete () method deletes the last element of an array and returns the deleted element.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();
Copy the code
Output: Banana, Orange, Apple
Relative: Remove the first element: shift ()
Splice () :
Method adds/removes items to/from an array and returns the deleted items. arrayObject.splice(index,howmany,item1,….. ,itemX)
Returns the deleted array
Sort () :
Used to sort the elements of an array.
The sorting order can be alphabetic or numeric and in ascending or descending order.
The default sort order is alphabetical ascending.
**var** arry = [40,100,1,5,25,10]; \ arry.sort(**function**(a,b){**return** a-b}); Var arry = [40,100,1,5,25,10]; \ arry.sort(**function**(a,b){**return** b-a});Copy the code
The reverse () :
Used to reverse the order of elements in an array.
Push (), pop(), Shift (), unshift(), splice(), sort(), reverse() all change the original array
Filter (), concat(), and slice() do not alter the array
filter()
The filter() method creates a new array of elements by checking all eligible elements in the specified array.
Filter () does not detect an empty array.
Filter () does not change the original array.
Concat () :
Method is used to concatenate two or more strings.
<script type="text/javascript">
var str1="Hello "
var str2="world!"
document.write(str1.concat(str2))
</script>
Copy the code
Slice () :
Method returns the selected element from an existing array.
arrayObject.slice(start,end)
The split () :
Splits a string into an array of strings.
Elements are separated by the specified delimiter (split(‘, ‘))
The join () :
The array_string () method is used to put all the elements of an array into a string.
Elements are separated by the specified delimiter (join(‘, ‘))