I can explain the difference between function declarations and function expressions.
- Well, at least one of them. Function declarations are hoisted, but with variables only the declaration (NOT the definition) is hoisted, so the variable still isn't defined until the code gets there.
I can explain what the value of this
is in a normal function.
- global object
I can explain what the value of this
is when called from the context of an object.
- it's the object.
I can explain how to explicitly set the value of this
in a function.
- i can pass the object in with call, apply, or bind.
I can explain the difference between call
and apply
.
- call's first argument is this and the rest are passed in individually. Apply's first argument is also this, but the rest of the arguments are passed in in an array.
I can describe an case where I might need to use bind
to avoid polluting the global scope.
- Asyncronous things where a function might be called later, but not right in this moment. But, when it is called, we want the value of 'this' to be the same as it is right in this moment.
I can explain how bind
works.
- It basically creates a new functon where 'this' is defined.