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 5
In Progress

JavaScript: Arrays with let and const

Yasin Cakal 12 Nov 2021
Lesson Progress
0% Complete

You may recall that variables can be declared using both the let and const keywords. Variables declared with let can be reassigned.

Variables declared with the const keyword are not reassignable. Elements in an array declared with const, on the other hand, remain mutable. We can change the contents of a const array, but we can’t reassign a new array or assign a different value.

 Pay close attention to the similarities and differences between the student array and the section array. Look closely at the example below:

let student = ['James', 'Tom', 'Iri', 'Siri'];
const section = ['A', 'B', 'C', 'D'];

student[0] = 'Frank';
console.log(student);

section[3] = 'E';
console.log(section);

//Output:[ 'Frank', 'Tom', 'Iri', 'Siri' ]
//       [ 'A', 'B', 'C', 'E' ]

Responses

Leave a Reply

%d bloggers like this: