Junior — Middle
Can you explain what a data array structure is?
sobes.tech AI
Answer from AI
An array is a data structure that represents an ordered collection of elements of the same type, stored sequentially in memory. In Node.js (JavaScript), arrays are dynamic and can contain elements of different types, but the concept of order and indexing is preserved.
Main characteristics of an array:
- Elements are accessible by index, starting from 0.
- The size of the array can change (in JavaScript).
- Allows quick access to elements by index.
Example of creating and using an array in Node.js:
const arr = [10, 'hello', true];
console.log(arr[0]); // 10
arr.push(42); // adding an element
console.log(arr.length); // 4
Arrays are widely used for storing and processing lists of data.