18
loading...
This website collects cookies to deliver better user experience
one-dimensional
or multi-dimensional
.one-dimensional array
is a type of linear array. Accessing its elements involves a single subscript which can either represent a row or column index. In other words, it only has one level which means it does not have any other arrays nested within itTwo-dimensional arrays
are most commonly used, also known as a table or matrix. A two-dimensional array associates each of its elements with two indexes.data types
. For example, we can have an array that can store numbers, strings, boolean values, arrays or even Objects.array literal notation
& another is using Array Constructor with the Keyword "new"
let arr = [item1, item2, item3,....];
let simpleArr = ['Swarnali', 93, true,'Roy', false, 8];
JavaScript Object
, which we will learn later in another blog. But for now, we need to know that arrays are capable of storing complex objects too.let complexArr = [
'Swarnali', 33, true, ['Roy', 93], {one: 1, two: "2"}
];
let rainbow = new Array();
let rainbow = new Array(7);
Array() constructor
.let rainbow = new Array('Violet','Indigo','Blue','Green','Yellow','Orange','Red');
let numbers = new Array(1,2,3)
,it creates an array with three numbers as it's elements.