Numeric Array
A numeric array is an array that contains only the numeric values as elements that are stored at different memory locations but in a consecutive manner.
Example: The below code example is an implementation of defining and using a numeric array.
Javascript
const numArr = [1, 2, 3, 4, 5]; console.log( "Numeric Array: " , numArr); console.log( "First element: " , numArr[0]); |
Output
Numeric Array: [ 1, 2, 3, 4, 5 ] First element: 1
Types of Arrays in JavaScript
A JavaScript array is a collection of multiple values at different memory blocks but with the same name. The values stored in an array can be accessed by specifying the indexes inside the square brackets starting from 0 and going to the array length – 1([0]…[n-1]).
A JavaScript array can be classified into multiple types:
Table of Content
- Numeric Array
- String Array
- Array of Arrays (2D Arrays)
- Array of Objects
- Mixed Arrays
- Array with empty values