JavaScript is a lanaguage developed by Netscape based on the Java programming langauge developed by Sun Microsystems.
JavaScript is used to create small scripts (programs) that are par of a web page source code. They are used to add interactivity to the page.
Here's an example of an JavaScript:
Variables
A variable is used to "represent" a piece of data (information)- example the name of the person using yuor web page.
Information can be numeric (i.e. you can do math operations, add, subtract, etc.) or non-numeric (also called string) (i.e. no math, things like names, phone numbers, etc.)
When using JavaScript, a good style is to declare all the variables at the beginning of the JavaScript.
The JavaScript instruction var is used to inform JavaScript of a variable, and if desired, assign some intial information to the variable.
The phone number example above is an illstration of a constant.
When deciding on variable name:
-no spaces
-case sensitive (i.e. Name and name are two different variables)
-use descriptive (meaningful) variable names
-do not use JavaScript words!
Arithemetic Operators:
+ add
- subtract
*multiply
/ divide
++ increase by one
-- decrease by one
Click here to see an examples of JavaScript in action: