Saturday, 15 June 2013

How arrays are used in JavaScript also explain the various functions which performed on array?



Array may be declared either using Array() constructor or using array literals.The different way of creating and using array in JavaScript are
Var arr = new Array();
Var arr = new Array(size);

Var arr = new Array(elements0, elements1…………elements n-1);
Var arr = (elements0, elements1…………elements n-1);
Properties and Methods of Array object :
Length – Provides a count of number of entries stored in an array.
Concat () – Combines the current array object with one or more array objects into a                                                          single array.
Pop () – Returns the value of  last item in an array and remove it from array.
Push() – Appends one or more items to the end of an array and returns its new length.
Reverse() – reverse the order of elements in the array.
Sort () – Sorts the elements of an array.

No comments:

Post a Comment