Learn JS the right way

👉 Note: Reading: You Don't Know JS Yet 1 - Get Started

Shortcut Notations

// Instead of
var car = new Object();
var.color = 'red';

// We use
var car = { color: 'red' };
// Instead of
var arr = new Array(1, 2, 3)

// We use
var arr = [1, 2, 3]
// The ternary notation
// Instead of 
var direction;
if (x < 1) direction = 1;
else direction = -1;

// We use
var direction = x < 1 ? 1 : -1;

Anonymous functions

// Instead of
var myApp = function(){
  var name = 'Thi';
  function getInfo(){
    // [...]
  }
}();

// We use
(function(){
  var name = 'Thi';
  function getInfo(){
    // [...]
  }
})()

Module pattern or singleton

var myApp = function(){
  var name = 'Thi';
  return getInfo(){
    // [...]
  }
}();

// Then
myApp.getInfo();