JavaScript Identifiers Variables And Constants

Identifiers, Variables and Constants


To model the real-world entities, we will need to name them to use them in the JavaScript program.

Identifiers are these names that help us in the naming of elements in JavaScript.

For example :


Identifiers should follow below rules:

  • The first character of an identifier should be letters of the alphabet or an underscore (_) or dollar sign ($).
  • Subsequent characters can be letters of alphabets or digits or underscores (_) or a dollar sign ($)
  • Identifiers are case-sensitive. Hence, tempCelsius and TempCelsius are not the same

Reserved keywords are part of programming language syntax and cannot be used as identifiers.

Variables and Constants

For temperature conversion app, in case of fever, temperature value will vary whereas the value for normal body temperature will always be the same.

The identifiers that we choose to hold data which varies is called as Variables

The identifier that we choose to hold data which does not vary is called Constant.

To declare a variable, we optionally use the 'var' keyword. The value for the same can be initialized optionally. Once the value is initialized, it can be modified any number of times in the program.

javascript variable

To declare a constant we use 'const' keyword followed by an identifier. The value is initialized during declaration itself and cannot be altered later.

javascript Constants

Value / Literal

Value or literal is the data related to the real-world entity.

Values can be of different types like number, string, boolean, etc.


number : It can be a floating-point and can be written with/without the decimal point


string : It is a text written within single quotes ‘ ’ or double quotes “ ”


boolean : There are 2 boolean values


#Identifiers_in_js #unexpected_identifier_javascript #unexpected_identifier_js #javascript_identifier #Variables_in_js #Variables_in_javascript #javascript_var #javascript_global_variable #javascript_variable_types #javascript_static_variable #javascript_const #javascript_const_var

(New page will open, for Comment)

Not yet commented...