Computer Science, asked by Dhagiya, 11 months ago

What is variable in JavaScript?

(Full explanation)​

Answers

Answered by neha9513
1
A Java variable is a piece of memory that can contain a data value. A variable thus has a data type. Variables are typically used to store value on which your Java program needs to do its operations.
Answered by Niruru
9

\bf\underline{What \:is \:variable?}

Variables can be thought of as named containers in the computer's memory. These containers are used to place data and refer to the value using the name.

An identifier is the name of a variable. An identifier can't use reserved keywords. Reserved keywords in JavaScript are - break, else, if, while etc.

_______________________ _ _

\bf\underline{Variable \:Declaration}

▪Variables in JavaScript can only be defined using the keyword "var".

▪The equal to (=) sign is used to assign a value to a variable.

▪User can either, separately declare tge variable and then assign values to it or straight - away declare and initialize the variables.

________________________ _ _

\bf\underline{Example \:of \:variables}

var x = 2

var y = 4

var sum = x + y

[output will be 6]

_____________________ _ _

Similar questions