JavaScript Array pop() Method
- Halaman Sebelumnya of()
- Halaman Berikutnya prototype
- Kembali ke Tingkat Atas Panduan Referensi Array JavaScript
Definition and Usage
pop()
The method removes the last element of the array and returns it.
Note:pop()
The method changes the length of the array.
Tip:To delete the first element of the array, use shift()
Method.
Instance
Example 1
Delete the last element of the array:
var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.pop();
Example 2
pop() returns the element it deletes:
const fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.pop(); // Returns "Mango"
Syntax
array.pop()
Parameter
No parameters.
Technical Details
Return Value: |
Any type *, indicates the array item that is removed. * Array items can be strings, numbers, arrays, boolean values, or any other object types allowed in arrays. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
All browsers fully support pop()
Method:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Page Related
Panduan:JavaScript Array
Panduan:JavaScript Array Const
Panduan:JavaScript Array Method
Panduan:JavaScript Sorting Array
Panduan:Iterasi Array JavaScript
Panduan:Metode push() Array JavaScript
Panduan:Metode shift() Array JavaScript
- Halaman Sebelumnya of()
- Halaman Berikutnya prototype
- Kembali ke Tingkat Atas Panduan Referensi Array JavaScript