- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Removing an element from the end of the array in Javascript
In this article, we are going to discuss how to remove an element from the end of the array in JavaScript. An array is a special variable, which can hold more than one value.
An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items together. This makes it easier to calculate the position of each element by simply adding an offset to a base value of the memory location of the first element of the array. The base value is index 0 for the first element in the array and the difference between the two indexes is the offset.
We use pop() function to remove an element from the end of the array in JavaScript. pop() function simply remove the last element in the array.
Syntax
Following is the syntax for removing an element from the array in JvaScript.
Array.pop()
Example
Following is the example program for removing an element from the end of the array in JavaScript.
<!DOCTYPE HTML> <html> <head> </head> <body> <script > const arr1 = [0,1,2,3,4,5] arr1.pop() document.write(arr1) </script> </body> </html>
Example
Following is the example program for removing an element from the end of the array in JavaScript.
<!DOCTYPE HTML> <html> <head> </head> <body> <script > const arr1 = ["java", "javaFX", "OpenCV"] arr1.pop() document.write(JSON.stringify(arr1)) </script> </body> </html>
Example
Following is the example program for removing an element from the end of the array in JavaScript.
<!DOCTYPE HTML> <html> <head> </head> <body> <script > const arr1 = ["java", "javaFX", "OpenCV"] const arr2 = ['HTML', 'CSS', 'JavaScript'] const concatedArray = arr1.concat(arr2); concatedArray.pop() document.write(JSON.stringify(concatedArray)) </script> </body> </html>