An array is a data structure that holds a list of elements.
Each element is identified by its index, starting from 0. You can create an array using square brackets []
You receive an API response with a list of user IDs and need to display the third ID; how would you store and access it using a JavaScript array, and what happens if fewer than three IDs are returned?
Given let nums = [1, 2, 3];, what does nums[5] evaluate to and why?
How would you add a new element to the end of an array without mutating the original array?
A function doubles each number in an input array using a for‑loop but sometimes throws undefined is not a function. Walk me through how you'd debug the issue.
When merging two sorted arrays you notice duplicate entries in the result. Explain a possible cause related to array methods and how you'd fix it.
Your React component receives a prop that should be an array of objects, but occasionally gets null. How would you safely iterate over it without causing a runtime error?
Our service processes JSON payloads containing arrays up to 10 million items. What memory or performance concerns arise with native arrays, and what alternatives or patterns would you consider?
We need a sliding window over a large array of events to compute a moving average in real time. Describe an efficient algorithm and discuss the trade‑offs of mutating the original array versus using a circular buffer.
A legacy codebase frequently uses Array.prototype.splice to remove items, causing UI jank. How would you refactor the code to improve responsiveness while preserving behavior?
Our public API returns large collections of data. We're debating between returning a plain JavaScript array versus a paginated cursor/stream. What architectural factors influence your recommendation?
Multiple teams share a utility library for array manipulation across micro‑frontends. How would you design a versioned, type‑safe helper module to avoid breaking changes?
We plan to migrate a performance‑critical component from JavaScript arrays to WebAssembly typed arrays. Outline the migration steps and the risks you would mitigate.