The script tag takes two important attributes:
Let us write our class example to print out “Hello World”.
Next, we call a function document.write which writes a string into our HTML document. This function can be used to write text, HTML, or both. So 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.