- Array indexing
- Properties of Arraylength
- Difference between length and indexing
Arrays are used to store several values of the same type in a single variable. In technical terms is a type of linear data structures. In simpler words, data is stored in a certain order that is one after the another. An array is a contiguous allocation of memory for data values of the same datatype.
Array indexing technically represents the position of an element. An element is a data value that is being stored in the array. Array indexing starts from 0 ,i.e. the first element’s position number is denoted by 0.
Array.length is an instance of type Array is of the object property length. The property length of Array returns the number of elements in the array. It can also help to update the length of the Array( that is increasing or decreasing the number of elements. The value of the property length is an positive integer ranging from less than 2 to 32nd power of 2 (232).
arr.length is : 5
PROPERTY ATTRIBUTES RELATED TO Array.length
- WRITABLE: If this attribute set to false, the value of the property remains unchanged.
- CONFIGURABLE: If this attribute set to false, then any attempts to delete the property or change its attributes will fail.
- ENUMERABLE: If this attribute set to true, the property will be iterated over during for loops.
DIFFERENCE BETWEEN LENGTH AND INDEXING
- Indexing is the position number of the element in an array while length is the number of elements present in any array.
- Indexing starts from 0 while length starts from 1.
- Indexing range starts from 0 to n-1 and length ranges from 1 to n.