1. Scope and Visibility
  2. How to put into HTML page
    1. use script tag
      1. use comments for dumb browsers
        1. // is the javascript comment, to prevent it from executing the closing html comment
    2. scripts in <head> section
      1. executed when called
      2. ensures that it's loaded before it might be needed
    3. scripts in <body> section
      1. executed while the page loads
    4. external scripts
      1. <script type="text/javascript" src="xxx.js"></script>
  3. Language
    1. Statements
      1. case sensitive
      2. separated by semi-colon or blank line
      3. can be grouped into blocks with { }
    2. Comments
      1. Single line //
      2. Multi-Line with /* */
    3. Variables
      1. must begin with a letter, or underscore
      2. declaration
        1. examples
          1. var x;
          2. var longNamedVariable;
          3. var x = 5;
          4. var longNamed = "Literal in quotes";
        2. notes
          1. variables can be redclared without losing their value
    4. Operators
      1. Assignment
        1. =
        2. +=
        3. -=
        4. /=
        5. *=
        6. %=
      2. Arithmetic
        1. +
        2. -
        3. /
        4. *
        5. %
          1. modulus
          2. x=5%2; // means x = 1
        6. ++
        7. --
      3. String concatenation
        1. +
          1. if you add a number and a string, result is string
      4. Comparison
        1. ==
        2. ===
          1. equal, value and type
        3. !=
        4. >
        5. <
        6. >=
        7. <=
      5. Logical
        1. &&
        2. ||
        3. !
      6. Conditional
        1. the shortcut if
        2. variablename=(condition)?value1:value2
          1. eg
          2. x=(4<5)?"yes":"no"; // x will be yes
    5. Conditional
      1. if
        1. if (condition) statement or block
        2. if (condition) {} else {}
        3. if (condition) {} else if (condition2) {} else {}
      2. switch
    6. Functions
      1. put them in the head
      2. not executed until called (naturally)
      3. example call
      4. procedures can be created by leaving out the return
    7. Popup Boxes
      1. alert("sometext");
        1. user must press OK
      2. confirm("sometext");
        1. user is offered OK or Cancel. returns true or false respectively
      3. prompt("sometext", "defaultValue");
        1. user is offered OK or Cancel. returns value or null respectively