legend internet ltd
solutions  support   online tools   resources   news    webmail               join legend
6th January 2009
  about careers contact home

Javascript Basics


In order to become a better JavaScript programmer, you need to understand the basics of Javascript. The basics aren't hard to understand, they're just a pain to get accustomed to :).

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

 

and that it its that simple!

 

tutorial from http://www.spoono.com/

Acceptable Use Policy   |   Terms and Conditions   |   Privacy Policy   |   Site Map   |   Jargon Buster