Skip to content

Instantly share code, notes, and snippets.

NPM

Useful commands

  1. List globally installed NPM packages and versions: npm list -g --depth=0

  2. Get directory where global modules are located: npm root -g

Update rules

'this' in JavaScript

The value of this differs depending on how a function is invoked. There're main rules and some exceptions.

Rules

  1. 'new' binding
function Foo() { this.bar = 'bar'; }