Excimer Sun Software
Posts : 152 Join date : 2010-05-07 Age : 31 Location : USA
| Subject: JavaScript for beginners Mon Aug 16, 2010 9:01 pm | |
| Hello! ESS here! Today I'm writing a tutorial on how to make your first JavaScript program, a "Hello World!" script. First off, I'm going to show you the whole thing, then I'll explain it line-by line. Here's the entire script: - Code:
-
document.write("Hello World!"); Yep! It's that easy! Now for the explanation: 1.) - Code:
-
document.write("Hello World!"); This is a built-in JavaScript method. This must begin with 'document' followed by a dot followed by 'write', after which must come an opening parenthesis, what you want to print, and then a closing parenthesis. The content of our parenthesis, "Hello World!", is a string. A string is a series of characters which is usually either taken as input or printed to a web document. Strings must be enclosed in either single or double quotes to be read properly. In our case, we want to say hello to the world, so we place, Hello World!, inside of quotes. If you leave quotes out, it will think that you are trying to print a variable and will complain about it if a variable of the same name as the text of the string hasn't already been defined. Also, at the end of the line, you will probably notice a semicolon. In JavaScript, every end of a line of code must be marked with a semicolon. There you go! That wasn't too bad, was it? If anyone has any questions, comments, constructive criticism, or discrepancies to point out in the tutorial, please feel free to post below. Also, HTML hello world coming soon! -ESS | |
|