Skip to content

Instantly share code, notes, and snippets.

JavaScript Functions

I can explain the difference between function declarations and function expressions.

  • function expressions are defined by var name = ... are invoked with name(...) but are not hoisted.
  • function declarations are defined by function name(...){...}, are invoked similarly, and are hoisted.

Rules for this:

    1. this is the global object (window, or global when in terminal)
    1. this is whatever object the function/method is being called from
    1. this is whatever you say this is.