- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 define integer constants in JavaScript?
ECMAScript allows usage of const to define constants in JavaScript. To define integer constants in JavaScript, use the const,
const MY_VAL = 5; // This will throw an error MY_VAL = 10;
As shown above, MY_VAL is a constant and value 5 is assigned. On assigning, another value to a constant variable shows an error.
Using const will not allow you to reassign any value to MY_VAL again. If you will assign a new value to a constant, then it would lead to an error.
- Related Articles
- How to define constants in C++?
- How to define character constants in C#?
- How do I define string constants in C++?
- What is a constant and how to define constants in Java?
- What are C++ Integer Constants?
- How to create constants in JavaScript? Explain with examples.
- Are there constants in JavaScript?
- How to define a method in JavaScript?
- How to define a function in JavaScript?
- How to define nested functions in JavaScript?
- How to implement constants in java?
- How to define custom JavaScript exceptions?
- How to convert a Boolean to Integer in JavaScript?
- How to define an Arrow Function in JavaScript?
- How to define a Regular Expression in JavaScript?

Advertisements