Notes on Maintainable JavaScript

Part one covers coding style to make team code look as if written by a single person. Part two covers programming practices, with many valuable JavaScript programming lessons. Part three is about automation, but the toolchain it introduces feels quite outdated by the end of 2016.

Read more

Notes on JavaScript: The Good Parts

I recently bought a few books, and this “JavaScript: The Good Parts” truly lives up to its name. It’s short in length with extensive appendices. The author is Douglas Crockford, the inventor of JSON – sounds impressive, and indeed the book is packed with insights. I benefited greatly from reading it!

Read more

Node.js Development Guide - Book Notes

Chapter 3

  1. Single Loading:

    require does not load modules repeatedly. No matter how many times require is called, the module obtained is always the same one.

  2. Overriding exports:

    When encapsulating an object into a module, using exports.Hello = Hello requires require(‘./singleobject’).Hello to obtain the object. This can be simplified as follows: module.exports = Hello; Then you can directly obtain the object: var Hello = require(‘./hello’); hello = new Hello();

  3. Creating Global Links:

    npm link express; This allows you to use the globally installed express in the current directory.

  4. Use npm init to interactively initialize a standard package.json;
    Publish a package: npm publish;
    After modifying the version field in the json file, republish to update the version;
    Unpublish: npm unpublish;

Read more

Notes on JavaScript: The Definitive Guide

  1. When the JavaScript interpreter starts, it creates a new global object and gives it a set of defined initial properties.
  2. Whenever a property of a string literal is referenced, the string value is converted to an object by calling new String(), and once the reference ends, this temporary object is destroyed.
  3. The “==” operator treats primitive values and their wrapper objects as equal, while “===” does not.
  4. Primitive values are immutable; object references are mutable.
  5. undefined converted to number:

    NaN, while null converted to number: 0, empty string converts to 0 and false.

Read more