Unshift, Push , Shift, Pop
Unshift is adding the first one of the array.
Push is adding the last one of the array.
Shift is deleting the first one of the array.
Pop is deleting the last one of the array.
Example
let customers = ['Eelyn', 'Ken', 'Mike'];
//Unshift
customers.unshift('Winnie');
console.log(customers)
Result :
['Winnie', 'Eelyn', 'Ken', 'Mike']
//Push
customers.push('Melissa');
console.log(customers)
Result :
['Winnie', 'Eelyn', 'Ken', 'Mike', 'Melissa']
//Shift
customers.shift();
console.log(customers)
Result :
['Eelyn', 'Ken', 'Mike', 'Melissa']
//Pop
customers.pop();
console.log(customers)
Result :
['Eelyn', 'Ken', 'Mike']
Top comments (0)