Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

difference between push and pop in javascript

/*
push() is used to add an element/item to the end of an array.
The pop() function is used to delete the last element/item of the array.
*/

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi"); // Banana,Orange,Apple,Mango,Kiwi

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop(); //Banana,Orange,Apple
 
PREVIOUS NEXT
Tagged: #difference #push #pop #javascript
ADD COMMENT
Topic
Name
5+5 =