A variable in JavaScript stores a value, which can be a string, number, letters or any other data type. Variables in JavaScript are labeled using the var, let, or const keyword, followed by a name in parentheses.
Once a variable is created, it can be given a value using the assignment operator (=). The value of a variable can be changed or updated at any time during the execution of a JavaScript program. Variables are essential in coding, since they allow developers to store and manage data.
We can create a variable like this example:
let variablename = 7;
Initialization is giving a value to a variable and if there is no value given to a variable it is called that it is declared.
JavaScript can also perform arithmetic operators. For these operations, we can use addition +, subtraction -, multiplication *, division /, remainder %, increment adds 1 to a variable ++.
decrement subtracts 1 from a variable – – ,
In JavaScript we also use concatenation where we connect two string into one.
Leave a Reply
You must be logged in to post a comment.