I’m aware of theses questions (1) and (2).
But i would like why push
method returns array length but pop
method returns value that has been removed, even though both methods seems very similar in opposite way.
Here an example code:
const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato'];
console.log(plants.pop());
// Expected output: "tomato"
console.log(plants.push("Onion"));
// Expected output: 5
console.log(plants);
// Expected output: Array ["broccoli", "cauliflower", "cabbage", "kale", "Onion"]