Jesper's blog
#6 Semicolons - Lessons Learned While Reading "Effective Javascript"
Submitted by Jesper on March 17, 2013 - 19:34In 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"
Submitted by Jesper on March 16, 2013 - 20:58In 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)
#4 Primitives - Lessons Learned While Reading "Effective Javascript"
Submitted by Jesper on March 15, 2013 - 22:37Javascript has five primitives available:
- Booleans
- Null
- Numbers
- Strings
- Undefined
You can also implicitely coerce Object properties/methods from primitives:
#3 Equality - Lessons Learned While Reading "Effective Javascript"
Submitted by Jesper on March 15, 2013 - 00:12#2 Double Trouble - Lessons Learned While Reading "Effective Javascript"
Submitted by Jesper on March 13, 2013 - 21:36All 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.
#1 "Use Strict" - Lessons learned while reading "Effective JavaScript"
Submitted by Jesper on March 12, 2013 - 22:53#1 "Use Strict"
"use strict" is a magic directive that was introduced in ES5.
Why would you enable it?
The Mozilla Developer Network sums it up quite well: