Javascript terminology

These examples illustrate the basic concepts you learned in your introduction to programming class. As you see, Javascript has slightly different syntax than Visual Basic, but the concepts -- the boldface Geek terms -- are the same.

You could create a page that looked exactly like one this using HTML, but this one was created by mixing scripts and HTML. What you are reading here is plain old HTML. What comes next is not HTML, it is generated by a script:

Now we are back to HTML.

You can see the script using the view source command on your browser. Note that the it was set off by a <script> tag. It is also enclosed in HTML comment delimiters so older browsers that do not understand JavaScript will ignore it.

The script uses the write method of the document object. The write method has one argument, a character string. Note that the script will not work if the argument is not the correct data type.

Here is another example:

Back to HTML again.

The script that generated the above five lines creates three variables and uses assignment statements. The last assignment statement also uses a numeric constant (3).

The final example illustrates the use of strings and string variables:

Here we are using a string variable and the plus (+) operator is used for concatenation. We also used the built in string functions toUpperCase and substring. Note that the JavaScript names are case sensitive.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.