array.sort()

Using sort() method you can define the sorting in an array. Returns the reference to the same array, the sort() method was applied but this time sorted. The default sort order is ascending, but a custom ordering rules can be applied using a compare function.

The compare function specifies a function that defines how the array will be sorted. It accepts to arguments (a, b) which are the first and second elements for comparison.

        
    

array.shift()

The shift() method removes the first element from an array and returns the removed element. After the method is applied to an array it reduces it's length. The method does not accept any parameter.

        
    

array.reverse()

Reverses the order of the given array. The first element becomes the last and the last is the first after calling this method on an array.

Returns the new array with the new order.

        
    

array.pop()

The pop() method removes the last element from an array and returns the removed element. After the method is applied to an array it reduces it's length. The method does not accept any parameter.

        
    

array.unshift()

Add elements at the beginning of an array. The function returns the new length of the array.

        
    

array.push()

This example demostrates how to add an element(s) at the end of an already defined array.  If the variable is not an array, it will return a “Uncaught TypeError” error.