Before using a variable in a JavaScript program, you must declare with the var keyword


<script type = "text/javascript">

//create variable and store data
    var x = 10;
    var y = 20;
    var total = x + y;

    //declare multiple variables
    var name, city, email;
    name = "Rathorji";
    city = "Mumbai";
    email = "";
    document.write(name + "<br>");
    document.write(city + "<br>");
    document.write(email + "<br>");

Phone, x, y and total is the variable name(container) in above program, container can store value

Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or at a later point when you need that variable.



JavaScript allows you to work with 3 data types −

  • Numbers:. 15, 44.2 etc.
  • Strings: "Hello world!" etc.
  • Boolean: true or false.