Skip to main content

Archive

Show more

What is the reverse of the push function in javascript

What-is-the-reverse-of-the-push-function-in-javascript


Question: What is the reverse of the "push" function in javascript?

Answer:

var myArray = ['a', 'b', 'c'];
console.log(myArray);


myArray.push('d');
console.log(myArray);

myArray.pop();
console.log(myArray);

output:

["a", "b", "c"] // Normal Array

["a", "b", "c", "d"] // After push('d') operation

["a", "b", "c"] // After pop() operation


We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.

Comments