

- 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
Are there constants in JavaScript?
Yes, constant exist in JavaScript. The value of const remains the same; you cannot change and declare it again. Create a read-only reference with the const declaration.
const MY_CONSTANT = "some-value";
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
- What are constants in C++?
- What are C++ Integer Constants?
- What are C++ Character Constants?
- What are Enumerated Constants in C++?
- What are C++ Floating-Point Constants?
- How to declare string constants in JavaScript?
- How to define integer constants in JavaScript?
- What are different types of constants in C++?
- What are Backslash character constants in C language?
- What are different types of constants in C language?
- Are there inline functions in Java?
- PHP Constants
- How to create constants in JavaScript? Explain with examples.
- Difference between C++ string constants and character constants
- What are the constants with an example in C language?
Advertisements