User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive

Variable (Variable) 

For that variable Essentially, its function is to store a value (value), which can sometimes be used to calculate the fee or charge of any kind. For reference or to check when needed. A variable in JavaScript, it begins with the word var followed by the variable name. 

An example of a variable declaration 


var x;

If a variable is declared dormant. It will be used later The conclusion is a variable that has no value at all. 


var x=10;

For this case, the variable is declared and assigned a value by an equal sign


JavaScript defines the basic data types (primitive data types) to use three types, that is.

- Numbers such as 3, 5, 7, 9. 

- Letters such as "I am", "SuperHero". 

-boolean (true or not the fact) as "true" (true), "false" (not really).


var age=23;
var name="Harry Potter";
var answer="Correct";
document.write(age + "<br>");
document.write(name + "<br>");
document.write(answer + "<br>");

This is the result:




Chapter 7 - JavaScript Data Types