To access a particular element of an array, use square brackets | MyArray[7] |
To know the length of an array | MyArray.length |
To search for the index of a particular element | MyArray.indexOf("orange") |
To add a new item to the end of an array | MyArray.push("apple") |
To fetch the last element of an array and remove it from the array | MyArray.pop() |
To sort an array | MyArray.sort() |
You don't need to remember all this, other than to know there's a powerful collection of methods available for use with arrays. You can find the full list at here and look them up when you need them.
|