JavaScript Statements
JavaScript is a sequence of
statements to be executed by the browser.
JavaScript is Case Sensitive
Unlike HTML, JavaScript is case
sensitive - therefore watch your capitalization closely when you write
JavaScript statements, create or call variables, objects and functions.
JavaScript Statements
A JavaScript statement is a
command to a browser. The purpose of the command is to tell the browser what to
do.This JavaScript statement tells the browser to write "Hello Dolly" to the web page:
|
document.write("Hello Dolly");
|
The semicolon is optional (according to the JavaScript standard), and the browser is supposed to interpret the end of the line as the end of the statement. Because of this you will often see examples without the semicolon at the end.
Note: Using semicolons makes it possible to write multiple statements on one line.
JavaScript Code
JavaScript code (or just
JavaScript) is a sequence of JavaScript statements.Each statement is executed by the browser in the sequence they are written.
This example will write a heading and two paragraphs to a web page:
Example
|
JavaScript Blocks
JavaScript statements can be
grouped together in blocks.Blocks start with a left curly bracket {, and ends with a right curly bracket }.
The purpose of a block is to make the sequence of statements execute together.
This example will write a heading and two paragraphs to a web page:
Example
|
You will learn more about functions and conditions in later chapters.
JavaScript Comments
JavaScript comments can be used
to make the code more readable.
JavaScript Comments
Comments can be added to explain
the JavaScript, or to make the code more readable.Single line comments start with //.
The following example uses single line comments to explain the code:
Example
|
No comments:
Post a Comment
Type Your Comments........