JavaScript Lessson 8

JavaScript Arrays

Lesson 7 Lesson 9

Notes:

Array:

  • An array is a special variable, which can hold more than one value at a time.
  • Arrays first index is 0, and the last index is length-1.
  • You refer to an array element by referring to the index number.
  • Arrays length is the numbers of elements.

sort() Method:

  • The sort() method sorts the items of an array.

length Property:

  • The length property sets or returns the number of elements in an array.

push() Method:

  • The push() method adds new items to the end of an array.

pop() Method:

  • The pop() method removes the last element of an array.

unshift() Method:

  • The unshift() method adds new items to the beginning of an array.

shift() Method:

  • The shift() method removes the first item of an array.