- Designed for creating network-centric applications
- Complementary to and integrated with Java
- Complementary to and integrated with HTML
- Open and cross-platform
The script tag takes two important attributes:
Let us write our class example to print out "Hello World".
Above code will display following result:
Whitespace and Line Breaks:
Because you can use spaces, tabs, and newlines freely in your program so you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.
Semicolons are Optional:
But when formatted in a single line as follows, the semicolons are required:
Note: It is a good programming practice to use semicolons.
- Any text between the characters /* and */ is treated as a comment. This may span multiple lines.
- Script in <head>...</head> section.
- Script in <body>...</body> section.
- Script in <body>...</body> and <head>...</head> sections.
- Script in and external file and then include in <head>...</head> section.
- Numbers eg. 123, 120.50 etc.
- Strings of text e.g. "This text string" etc.
- Boolean e.g. true or false.
- Local Variables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.