07 Arrays
07 Arrays
Array elements
Array name
array[0]=currentDate.getDate(); //objects
array[1]= name(); //functions
array[2]= fruits;//array
• The real strength of JavaScript arrays are the
built-in array properties and methods:
1. length;
2. toString();
3. join()
4. pop()
5. push()
6. splice()
7. slice()
8. sort()
9. reverse()
• The length property of an array returns the
length of an array (the number of array
elements).
• The JavaScript method toString() converts an
array to a string of (comma separated) array
values.
The first parameter (2) defines the position where new elements
should be added (spliced in).
The second parameter (0) defines how many elements should
be removed.
The rest of the parameters ("Lemon" , "Kiwi") define the new elements
to be added.
The splice() method returns an array with the deleted items:
• The slice() method slices out a piece of an array
into a new array.