Peter
New Member
God
Posts: 6
|
Post by Peter on Jun 18, 2004 11:52:07 GMT
Another simple one for the collection What's a variable? I hear you say.... Answer: A variable is a place in which you can store data When you come to naming variables you must be aware of certain things. A variable can have any letter, digit and even the underscore "_" may be used, but the variable may not begin with a digit. Example of valid variables: abcd
my_variable
var32123
To create a new variable, you use the Javascript "var" keyword. I'll show you with a small script. <script type="text/javascript"> <!--
var my_message = "My First JavaScript Variable";
alert(my_message);
//--> </script>
The text string is stored inside the variable called my_message. Then the variable name is called to the javascript alert function, so when you run the script you will get an alert box displaying the string which is stored in the variable. Peter This tutorial may not be reposted without permission
|
|