Create an array - 01

One way we can create an array with array literals. Array literal creates an array by wrapping the array items with square brackets. 

We can have an array that holds all the same data type or an array that holds different data types.








Let’s take a closer look at the syntax in the array example:

  • The array is represented by the square brackets [ ] and the content inside.
  • Each content item inside an array is called an element.
  • There are three different elements inside the array.
  • Each element inside the array is a different data type.


We may save an array to a variable.

let newYearsResolutions = ['Keep a journal', 'Take a falconry class', 'Learn to juggle'];



Post a Comment

Previous Post Next Post