What is variable, how to declare, what to consider to declare a variable in JavaScript

What is variable, how to declare, what to consider to declare a variable in JavaScript

JavaScript tutorials: Variable

JavaScript is a client-side scripting language or browser scripting language. Simply put, JavaScript is a programming language for the web or HTML that you can use to manage any HTML content at will. It includes data type, operator, some important objects, function methods required for web pages, etc.
Today I will learn about the first lesson variable of the JavaScript module.

What is a variable?

  • => Variable in Bengali means variable or changeable.
    => That means anything that can be changed is, therefore, a variable.
    => Now, in the language of programming,
    => The variable that changes the data value.

To declare a variable with the var keyword in JavaScript.

The question may come,

What is the variable declaration?

If you want to write a variable in JavaScript, you have to declare it and that is a variable declaration.
Now let’s see what it takes to declassify a variable.

How to declare a variable?

It takes a total of five terms to declare a variable!
  • Variable,
  • variable identifier,
  • assignment operator,
  • value
  • end of the statement.
When declaring a variable, the first three letters of the variable have to start with the var keyword.
Below is a variable declared.
Var age = 35;
  • Here “var” is the short form or keyword of the variable.
  • age” is the variable identifier (it must be unique),
  • =” is the assignment operator,
  • 35” is the variable value
  • ;” Being the end of the statement.
Let’s look at another example,
Var ageAnik = 35;
Here,  a name is added to the variable identifier and it is also a variable identifier but it refers to the identifier in a more precise way. (To understand, we can assume that it is a modifier of a variable identifier that indicates someone’s age.)
When writing multiple variable identifiers, you have to start with a Capital letter and it is called the Camel case.
Output
console.log (ageAnik);
The output will be the value declared here i.e. 35.

General rules for constructing names for variables (unique identifiers) are:

  • Names can contain letters, digits, underscores, and dollar signs.
  • Names must begin with a letter
  • Names can also begin with $ and _.
  • Names are case sensitive (y and Y are different variables)
  • Reserved words (like JavaScript keywords) cannot be used as names
  • JavaScript identifiers are case-sensitive.
  • What is variable in JavaScript | solovend.com

Leave a Reply

affiliate money machine

Hey, don't miss
Free
‘Digital Marketing’ E-book

Affiliate Money Machine

Sign up for our newsletter with the best digital marketing tools and affairs inspirations.