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.