Saturday, November 20, 2010

Lesson 5: Translating Javanese, Beginner

Since Blogger has been so uncooperative with coding, and because there's more you can do with javascript than I can possibly show here on my blog, I'm switching tactics. Now I'm just going to explain the different parts of javascript code.

Some Formatting Basics:
  • Most javascript goes in the document head (which is why I've been having trouble), but sometimes it can go in the body (like the alerts in Lessons 1 and 2).
  • Javascript is case sensitive, so don't get lazy with the shift key. The convention is to uppercase the beginning of words in a line, like this: var paraCollection = document.getElementByTagName( 'p' );
  • Semicolons mark the end of statements.
  • Curly braces enclose sections of a script.
  • When counting, start at 0, not 1.
  • White space doesn't matter, so use as much as you want.
  • Like HTML can have comments with , Javascript can have comments with // at the beginning of one line, or /* */ enclosing a multi-line comment.
  • You can use ' or ", but make sure you're consistent when pairing them up.

No comments:

Post a Comment