Whats const?
A const variable cannot be reassigned
You have to know:
Variables defined with const cannot be Redeclared.
Variables defined with const cannot be Reassigned.
Variables defined with const have Block Scope.
Const Samples Overview?
const aq = 4.44267568; aq = 1.44; // This will give an error aq = aq + 70; // This will also give an error
const PI = 3.14159265359; //Correct
const PI; //incorrect PI = 88.6546762; //incorrect
// You can create a constant array: const cars = ["Tesla", "Jeep", "BMW"]; // You can change an element: cars[0] = "Toyota"; // You can add an element: cars.push("Audi");
const cars = ["Tesla", "Jeep", "BMW"];
cars = ["Toyota", "Volvo", "Audi"]; // ERROR
// You can create a const object: const car = {type:"Fiat", model:"100", color:"pink"}; // You can change a property: car.color = "red"; // You can add a property: car.owner = "Bill";
const car = {type:"Fiat", model:"200", color:"Red"};
car = {type:"Volvo", model:"EX60", color:"pink"}; // ERROR