Pop() Method

It is used to delete an element at the end of the array. 

javascript




pop() {
    let item = this.data[this.length-1];
    delete this.data[this.length-1];
    this.length--;
    return this.data;
}


In the above example, the item variable will store the last element from the data object and perform deletion of the last element and then, it will decrease the length by 1 and return the object. 

Implementation of Array class in JavaScript

This article implements Arrays using JavaScript. An Array is a simple data Structure, in which elements are stored in contiguous memory locations. Implementation of arrays performs various operations like push (adding element), pop (deleting element) element at the end of the array, getting the element from a particular index, and inserting and deleting an element from a particular index.

Similar Reads

Implementing Array class in JavaScript:

javascript // User defined class Array class Array {       // Create constructor     constructor() {               // It store the length of array.         this.length = 0;                   // Object to store elements.         this.data = {};     } }...

Custom method implementations of array class:

...

Push(element) Method:

Push() Method  Pop() Method insertAt() deleteAt() getElementAtIndex()...

Pop() Method:

This method is used to push an element at the end of the array....

insertAt() Method:

...

deleteAt(index) Method:

It is used to delete an element at the end of the array....

getElementAtIndex(index) Method:

...

Implementation of The Array Class along with Custom Methods:

This function is used to insert an element at the given index....