

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use 'const' keyword in JavaScript?
The value of const remains the same, you can’t change and declare it again. Create a read-only reference with the “const” declaration.
With const, you can declare local variables with block scope rather than function scope. Let’ say we have a constant variable a. After declaring a value like a constant variable, you can’t assign a new value to it.
// declared ‘a’ as a constant variable. const a = 150; // Assigning a new value to `a` will fail since ‘a’ is a constant variable a= 0; a++; // The below declarations won’t work var a = 0;
- Related Questions & Answers
- const keyword in Dart Programming
- How to use void keyword in JavaScript?
- How to use the debugger keyword in JavaScript?
- What is the const Keyword in C++?
- Function overloading and const keyword in C++
- JavaScript Const
- Difference between readonly and const keyword in C#
- How to use the 'with' keyword in JavaScript?
- Const vs Let in JavaScript.
- What is the difference between #define and const Keyword in C++?
- Difference between const int*, const int * const, and int const * in C
- Difference between const int*, const int * const, and int const * in C/C++?
- Why do we use const qualifier in C++?
- Difference between const char* p, char * const p, and const char * const p in C
- What is the difference between const int*, const int * const, and int const *?
Advertisements