1. Introduction
Array is a novel sort of variable which might retailer a number of values. It’s enclosed in sq. [] brackets.
Syntax
const variable_name= [//"data"];
2. Its significance
Array may be very useful because it makes our work simpler and in addition make code easier and easy. We needn’t create a number of variables as we are able to retailer a number of sort of knowledge in a single.
NOTE
We will modify the information in array as soon as declared.
3. Array size
We will entry the no of things within the array utilizing ‘size’ key phrase.
For instance:
const vehicles= ['BMW', 'Audi', 'Mercedes'];
console.log(vehicles.size)
Output for above instance is:
3 is output, as there are three objects within the array.
Instance:
const laptops = ['Lenovo', 'Dell', 'HP'];
console.log(laptops.size)
output:
3
4. Array Push
Array Push provides the merchandise on the finish of the sequence.
For instance:
const fruits= ['Apple', 'Mango', 'Banana'];
fruits.push('Orange');
console.log(fruits)
Output:
[“Apple”, “Mango”, “Banana”, “Orange”]
In above instance, an array named fruits was created and in assertion 2, utilizing push key phrase, ‘orange’ was added within the record.