Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
1146
JavaScript Variables
Introduction
Variables are an important part of programming languages.
They are basically used to store values or information. The variables can then
be used in a string or on an element or wherever you need them. Variables
should be declared before you use them, however it is not necessary. A variable
name should start either with a letter or with an underscore. Nothing else is
allowed to start a variable name. The following are valid variable names: x, X,
_x, _X or _x99. Note that JavaScript is case-sensitive – so the variables x and
X are two different variables.
Example
<html>
<head>
<script type="text/javascript">
var
_MyString = "This is the value of my string."
document.write(_MyString)
</script>
</head>
<body></body>
</html>
Output
Scope
Variables can be either defined globally or locally. If you
define a variable in a function then it is a local variable. The variable is
not accessible out of the function. As soon as the function ends the variable
is destroyed. If you define a variable outside of a function, then it is called
a global variable. This variable is available and accessible everywhere.