How to implement Array.prototype.at? JavaScript Interview Question | Problem Solving | JavaScript Polyfills
@Yomesh Gupta

JavaScriptBeginner
285
Do you see value in our efforts?

Devtools Tech is a free platform for Frontend Engineers. It takes a lot of time, effort, and finanical resources to keep the platform running. If you see any value in our work and would like to support us then you can do using the following options.

InternationalDomestic

In this question, the candidate needs to implement a function customAt that mimics the behaviour of Array.prototype.at method.

More about Array.prototype.at

The at() method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.

Examples

const array = [5, 12, 8, 130, 44];

console.print(array.customAt(2)); // prints 8
console.print(array.customAt(-1)); // prints 44
console.print(array.customAt(100)); // prints undefined

Submission

Start the timer, complete your solution, and test it against the testcases provided by the platform. Ideally, you should finish this question within 15 mins. Share your solution with us -- https://twitter.com/devtoolstech

Loading IDE...