Skip to content

Instantly share code, notes, and snippets.

View BIWhitfield's full-sized avatar

Ben BIWhitfield

View GitHub Profile
@BIWhitfield
BIWhitfield / this-rules.md
Created June 22, 2017 13:55
Summary of the rules for the binding of `this` in JavaScript

1. Implicit Binding

  • Occurs automatically and implicitly when a function is called as a method of an object.
  • this points to the object to the left of the dot.
  • Most common and useful rule, ~80% of the cases.
let me = { name: "Mauro", sayName: sayName };

function sayName () {