Javascript

JavaScript Engines

Browser

  • Chrome: V8
  • Firefox: SpiderMonkey
  • Safari: Nitro

Beyond Browser

  • Nashorn: released with Java 8, to replace Rhino, another JavaScript engine that was implemented in Java. Actually, Nashorn is the German word for rhino.
  • Node.js: uses the Google V8 JavaScript engine to execute code

JavaScript Ecosystem

Most popular web frameworks

  • React: developed and used by Facebook
  • Angular: developed by Google
  • Vue

Typecheck

  • TypeScript : can be compiled to JavaScript

    • better tooling: advanced autocompletion, navigation, and refactoring
    • developed by Microsoft
    • SUPERSET OF JAVASCRIPT, javascript code is also valid typescript code
  • Flow: also developed by Facebook, so works fine with React

Other notable libs

Add Padding

function addPadding(num, width) {
  var str = num.toString();

  while (str.length < width) {
    str = "0" + str;
  }
  return str;
}

Set default value inside function

function foo(params) {
  var settings = params || {};
}

in vs. hasOwnProperty()

  • in: check prototype chain, all inherited properties will be included.
  • hasOwnProperty(): only check its own properties.

es6 backtick

Template literals can be used multi line and may use "interpolation" to insert the content of variables:

var a = 123,
  str = `---
   a is: ${a}
----`;
console.log(str);

Will output:

---
   a is: 123
---