I can explain the difference between function declarations and function expressions.
- A function declaration is a named function that is not stored as a variable. An expression is an anonymous function set to a variable.
function logSomething(thing){
console.log('something');
}```
```Expression:
var logSomething = function(something){
console.log('something');
}```
I can use declarations above where they are written, expressions I can't. BAM.
I can explain what the value of `this` is in a normal function.
* `this` is the window/global object. Unless otherwise defined.
I can explain what the value of `this` is when called from the context of an object.
* `this` is whatever object its being called from - whatever 'context' it's wrapped in.
I can explain how to explicitly set the value of `this` in a function.
* `this` is whatever you say it is if you define it with `call` or `apply`. The developer always wins!
I can explain the difference between `call` and `apply`.
* `call` allows you to redefine what 'this' is, and pass additional arguments into a function
* `apply` does the same thing but the additional arguments are an array.
I can describe an case where I might need to use `bind` to avoid polluting the global scope.
* Asynchronous things where you need to call `this` at a later time and really care about what `this` is.
I can explain how `bind` works.
* `bind` is similar to `call` and `apply` however it doesnt immediately call the function, but holds onto it until it is needed and defines `this` as you see fit.