Quick Reference: Scripting with JavaScript


Unless you are familiar with programming, you have encountered a number of unfamiliar ideas and constructions as you’ve worked with JavaScript. Although this chapter cannot go into every possible detail, some of the aspects of JavaScript “grammar” you have used thus far are reviewed in the following table:

To Do This

Use This

Add a single-line comment to JavaScript

// Your comment goes here

Add a multiple-line comment to JavaScript

/* Your comment goes here */

Hide JavaScript from HTML

<script> <!-- script goes here -->
</script>

End a complete JavaScript statement

Use a semicolon (;)

Use a method or function. The method or function’s arguments go inside parentheses (Arguments are the specific actions a method
or function performs.)

method( ) function( )
document.write("Hello")

Connect multiple JavaScript statements

Enclose in curly braces { }

Connect (concatenate) groups of literal characters (strings)

Use the "plus sign" (concatenate operator)
"string" + "string" + "string"

Say that something is “equal to” something else
(as in 2 + 3 = 5)

Use double equal signs ( = = )
if {date = = Today}

Assign a value to a variable (something that
can change)

Use a single equal sign ( = )
var = Variable




How to Do Everything with HTML & XHTML
How to Do Everything with HTML & XHTML
ISBN: 0072231297
EAN: 2147483647
Year: 2003
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net