Monday, July 26, 2010

little javascript discoveries, aka shame on me :)

Shame on me, after going through this cheatsheet I have realized there were some things I didn't know about javascript:
  •  variables declared with var are declared locally, variables declared without var are not;
  • to check whether the value is undefined, one has to use the following construct: 
    • if (x === undefined)
    • and NOT if (x==undefined) because it will always be true.
They forgot to clearly mention the difference between normal arrays:
  • x = [1,2,3];
and associative arrays
  • x = {'a':1, 'b':2, 'c':3};
though they do refer to those as "hash literals" (the document seems to be a bit old though).