Defining Variables
Defining variables is an integral part of Javascript. Without
variables, functions could not be run, arrays could not be
made, and so on. To define a variable, all you have to type
is:
<Script Language="Javascript">
name;
</script>
There, you have just created a variable that is called name.
But, it doesn't do anything. The magical equals sign makes
variables viable:
<Script Language="JavaScript">
name = x + 1;
</script>
Now, the variable called name, is x + 1. Say x = 5, then
name would equal 6, right? Of course it would.
<Script Language="JavaScript">
x = 5
name = x + 1;
</script>
Printing Values
Great, you know how to define things, but now, you have to
print the things that you have defined. To do this, we use
the
document.write();
command. Here is what the example above would look like:
<Script Language = "JavaScript">
x = 5
name = x + 1
document.write(name);
</script>
This would produce:
6
|