bhylu.com

Advertisements

JS Array const

Const protects the array binding from reassignment. Its elements can still be inserted, removed, or replaced.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const tasks = ["Measure"];
tasks.push("Cut");
tasks[0] = "Check measurements";
console.log(tasks);

What happens

The same array now holds two updated tasks.