About 1,620,000 results
Open links in new tab
  1. JavaScript Const - W3Schools

    // You can create a constant array: const cars = ["Saab", "Volvo", "BMW"]; // You can change an element: cars[0] = "Toyota"; // You can add an element: cars.push("Audi");

  2. const - JavaScript | MDN - MDN Web Docs

    Mar 19, 2025 · The const declaration declares block-scoped local variables. The value of a constant can't be changed through reassignment using the assignment operator, but if a constant is an object, its properties can be added, updated, or removed.

  3. JavaScript const - GeeksforGeeks

    Feb 12, 2025 · It is used to declare variables whose values need to remain constant throughout the lifetime of the application. const is block-scoped, similar to let, and is useful for ensuring immutability in your code. Unlike let, the primary feature of const is that it cannot be reassigned once it has been initialized. Syntax.

  4. JavaScript const: Declaring Constants in ES6 - JavaScript Tutorial

    ES6 provides a new way of declaring a constant by using the const keyword. The const keyword creates a read-only reference to a value. By convention, the constant identifiers are in uppercase. Like the let keyword, the const keyword declares blocked-scope variables.

  5. Are there constants in JavaScript? - Stack Overflow

    Sep 25, 2008 · Introducing constants into JavaScript is at best a hack. A nice way of making persistent and globally accessible values in JavaScript would be declaring an object literal with some "read-only" properties like this:

  6. What does Const Do in JavaScript - GeeksforGeeks

    Jun 5, 2024 · In JavaScript, const is a keyword used to declare constants. Once assigned, the value of a constant cannot be changed. It provides a way to create read-only variables. Attempting to reassign a const variable will result in a syntax error. These are …

  7. javascript - How to get all variables including constants - Stack Overflow

    I have been trying to find a way to find all constants in javascript. I have found I can get all global variables with for (let i in window) { console.log(i); };

  8. JavaScript const Statement - W3Schools

    Creating a variable in JavaScript is called "declaring" a variable: A const variable must be assigned when it is declared. Required. The name of the variable. Required. A value to be assigned to the variable. When to use JavaScript const? As a general rule, always declare a variable with const unless you know that the value will change.

  9. JavaScript const Keyword Explained with Examples | sebhastian

    Oct 27, 2023 · The const keyword is used to declare a variable that can’t be changed after its declaration. This keyword is short for constant (which means “doesn’t change”), and it’s used in a similar manner to the let and var keywords. You write the keyword, followed it up with a variable name, the assignment = operator, and the variable’s value:

  10. Defining Constants in JavaScript | Useful Codes

    In JavaScript, constants are defined using the const keyword. The syntax is straightforward: Here, constantName serves as the identifier for your constant, and value is the data you wish to store.

  11. Some results have been removed
Refresh