Saturday, August 30, 2014

Javascript is Very Forgiving

Where is the "hola"? It is there but it is also missing.
> var list = ["one", "two"];
  undefined
> list[2] = "three";
  "three"
> list
  ["one", "two", "three"]
A third element can be added to the array but that is not the only way to add data to a Javascript object.
> var greetings = ["hi", "howdy"];
  undefined
> greetings["es"] = "hola";
  "hola"
> greetings["es"]
  "hola"
> greetings
  ["hi", "howdy"]