Array objects in JavaScript Assignment Help
Array objects
Array object is one of the data structures which occupies continuous memory location to store collection data. Array object consists single variable to hold collection of data, each data is accessed with the help of array index value.
19.1 Array object properties
It has the following properties such as length, index, input, constructor, proto type.
Length:
It specifies the maximum number of elements it can hold.
Index:
Each array object is identifies using index value. Usually the index value starts with ‘0’.
Input
The output of expression and string match can create array.
Constructor
Array objects in JavaScript Assignment Help Through Online Tutoring and Guided Sessions at MyAssignmentHelp
Returns the memory address of the array object
Prototype
This property is used for adding more properties and methods to an array object.
19.2 Array creation
var array_name=[list of items]; var stu=[“mala”,”kala”,”neela”,”sheela”]; (or) var array_name=new Array(“list of items”); var stu=new Array(“mala”,”kala”,”neela”,”sheela”);
Example
![Array Objects Array Objects](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/array-objects-img1.jpg)
19.3 Array Methods
every()
It checks every array element to check whether given condition is satisfied or not
filter()
It selects the array elements those are satisfying the given condition.
concat()
It combines two array elements into one array.
join()
The function joins all array elemts into one string.
indexOf()
It returns the index value of first element.
forEach()
To retrieve each element of an array
lastIndexOf()
It returns the index value of last element.
pop()
To delete the last array element from an array and returns that deleted element.
push()
To add new array elements into an existing array
reduce()
To perform operation on two array elements from left to right until reaches the one value.
reduceRight()
It is same like reduce(). But difference only in direction. It performs operation from right to left.
reverse()
It displays the array elements in descending order.
slice()
Fetches only part of array.
sort()
Arrange the elements of an array in alphabetical order or numerical order.
unshift()
It is same like push operation. It also adds elements into an array but in front of the array operations are performed.
shift()
Deletes the first element from an array.