Jesper's blog

#6 Semicolons - Lessons Learned While Reading "Effective Javascript"

In Javascript, semicolons are optional. However, for the sake of simplicity, it's best to include them. Furthermore, when always including semicolons, it's important to remember that the following statements may not have a newline before their arguments: (JS will implicitely insert a semicolon)

  • ++
  • --
  • break
  • continue
  • return
  • throw

#5 Operator Equals - Lessons Learned While Reading "Effective Javascript"

In Javascript you have two equals operators: implicit coercion equals operator (==) and strict equality operator (===). The former will try to coerce different types and attempt equality checks, while the latter will only operate without any conversions.

Because of these properties, the "===" operator is prefered, as it's explicit nature yields less potentially tricky (buggy) code due to non-obvious conversions. (and helps with code readability)

 

#2 Double Trouble - Lessons Learned While Reading "Effective Javascript"

All numbers in Javascript are doubles - double precision floating point numbers. It's therefore very important to remember that rounding errors *do* occur, and when accumulated, can cause serious mischief! For example, what does "0.2 + 0.4" equal? "0.6"? Think again. 

Pages