I can explain the difference between function declarations and function expressions.
- function expressions are defined by
var name = ...
are invoked withname(...)
but are not hoisted. - function declarations are defined by
function name(...){...}
, are invoked similarly, and are hoisted.
Rules for this
:
-
this
is the global object (window, or global when in terminal)
-
this
is whatever object the function/method is being called from
-
this
is whatever you say this is.