What is the use of declaring variables in JavaScript?

JavascriptWeb DevelopmentFront End Technology

Before you use a variable in a JavaScript program, you must declare it. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.

Variables are declared with the var keyword as follows.

<script>
   <!--
      var rank;
      var points;
   //-->
</script>

You can also declare multiple variables with the same var keyword as follows −

<script>
   <!--
      var rank, points;
   //-->
</script>

This is also you can assign values −

var rank = 2;
var points = 100;


raja
Ali
Published on 16-Jan-2018 11:13:32
Advertisements