You need Login/Signup to run/submit the code.
How to implement Array.prototype.pop? JavaScript Interview Question | Problem Solving | JavaScript Polyfills
@Yomesh Gupta
In this question, the candidate needs to implement a function customPop
that mimics the behaviour of Array.prototype.pop
method.
More about Array.prototype.pop
The pop()
method removes the last element from an array and returns that element. This method changes the length of the array.
Examples
const array = [1, 2, 3];
const popped = array.pop();
// prints 3
console.print(popped);
// prints [1,2]
console.print(array);
Syntax
pop()
Return value
The pop()
method removes the last element
from an array and returns that value to the caller. If you call pop() on an empty array, it returns undefined
.
Submission
Start the timer, complete your solution, and test it against the test cases provided by the platform. Ideally, you should finish this question within 30 mins. Share your solution with us -- https://twitter.com/devtoolstech