JavaScript Syntax

JavaScript Syntax Print E-mail
Contributed by Joe   
Saturday, 08 July 2006

JavaScript Syntax List

  • Comments: Comments are human-readable descriptions.you can add to your script to make your script easier to understand and maintain.
  • Conditionals: Conditionals are logical constructs that you can add to your script to decide whether a particular condition is true or false at runtime. The most basic conditional is if-else.
  • Functions: Functions are named groups of statements that you define once, and then reuse to your heart’s content.
  • Loops: Loops are specialized forms of conditionals. You can add a loop
    to your script that checks a particular condition multiple times, executing whatever JavaScript code you like, until that condition becomes true or false. Common examples of loops include the for, while, and do-while
  • Operators: Operators are the JavaScript answer to conjunctions.Operators
    include the commas, periods, and other symbols that you use to compare and assign values to variables.
  • Variables: Variables are named placeholders that represent the bits of data that you work with in your scripts.

 

JavaScript Syntax comments

The first type of comment is a single-line comment. It begins with two forward slashes, and it’s good for only one line. Here’s an example of a single-line comment.
// Single-line comments demo

The second type of comment is a multiple-line comment. Because it spans
multiple lines, you have to tell it where to start (by using a forward slash followed by an asterisk) and where to end (by using an asterisk and then a forward slash). For example:
/* This comment can span multiple lines.  */

JavaScript Syntax comments if-else

The if-else conditional expression is one of the most powerful constructs in JavaScript.
You use if-else to test a condition:
If the condition is true, the JavaScript interpreter executes all the statements that follow the if clause.
If the condition is false, the JavaScript interpreter executes all the statements that follow the else clause (if the else clause exists).
Here’s the generic description of how to use if-else:

if (condition) {
statements
}
[ else {
statements

Last Updated ( Saturday, 08 July 2006 )

  home              contact us

 

©2006-2008 DeveloperZone.biz   All rights reserved     powered by Mambo Designed by Siteground