and ends with </script>
var _welcomeMessage="Welcome to WebTrainingRoom";
In above example, we declared a variable called _welcomeMessage
, then assigned a string value within "".
- To declare a variable use var then name of the variable
- Once you assign a value to that variable, that become the data type of variable, in our case above variable become string type after value assigned
- You cannot change the data type of any variable within the program scope, suppose you have written var x=10;, now within the program you cannot write var x="Hello World";
Here you will be learning below topics