Tuesday 4 September 2007

AJAX & Web 2.0 Tutorial (Section 1) - Javascript Basics




  1. Javascript has nothing to do with Java.
  2. Javascript is a client side language, it is executed by the browser, not the server.
  3. Javascript can be used to manipulate HTML documents, this allows the programmer to do all sort of nifty things. (Like AJAX)
  4. Creating Valid HTML documents is the first step to giving yourself an easier JavaScript existence, things will start working sooner, and generally break in more predictable and understandable ways.
  5. Many developers new to JavaScript look at the source code of their application to look for output, which seems like it should hold the answer, it doesn’t. When you modify the document using JavaScript you’re modifying the document in memory, the source doesn’t
    actually change.
  6. Proper code needs a finished document with which to work, store your initialization code inside a function called in the body tag’s onload event. It’s good practice to encapsulate
    your code within a function anyways.
  7. JavaScript variables are very similar to PHP
    1. Loosely Typed
    2. Number - Floating point number, stored internally using 64bit representation
    3. Boolean - true or false
    4. Strings - Encapsulated within quotes (no heredoc)
    5. Objects
  8. Best way to convert text into a number is by using the Number() function, if it runs into a problem it will return produce.
  9. To convert a value into an Integer use the parseInt(value, base) function. It accepts both
    the object containing the value you wish to convert, and the base at which the conversion should take place (avoiding those silly issues with leading zeros)

No comments: