Back to Course

Introduction to JavaScript

0% Complete
0/0 Steps
  1. JavaScript: Basics
    9Topics
    |
    10 Quizzes
  2. JavaScript: Variables
    9Topics
    |
    10 Quizzes
  3. JavaScript: Conditional Statements
    10Topics
    |
    11 Quizzes
  4. JavaScript: Functions
    10Topics
    |
    11 Quizzes
  5. JavaScript: Scope
    6Topics
    |
    7 Quizzes
  6. JavaScript: Arrays
    11Topics
    |
    12 Quizzes
  7. JavaScript: Loops
    8Topics
    |
    9 Quizzes
  8. JavaScript: High Order Functions
    3Topics
    |
    3 Quizzes
Lesson 6, Topic 2
In Progress

JavaScript: Create an Array

Yasin Cakal 12 Nov 2021
Lesson Progress
0% Complete

Using an array literal is one way to create an array. An array literal is formed by enclosing items in square brackets [ ]. Remember from the previous exercise that arrays can store any data type — we can have an array with all the same data types or an array with different data types.

['element example', 10 , true];

Let’s look at the syntax in the array example more closely:

  • The square brackets [ ] and the content within them represent the array.
  • Each item of content within an array is referred to as an element.
  • The array contains three distinct elements.
  • Each array element represents a different data type.

An array can also be saved to a variable. You may have noticed that we did something similar in the previous exercise:

let LearnJavaScript = ['Sign up on CodeOfCode', 'Complete 1 lesson a day', 'Write and check codes'];

Responses

Leave a Reply

%d bloggers like this: