I can explain the difference between function declarations and function expressions.
-Yes. Declarations are hoisted and available right away, while expression values are undefined until they are declared.
I can explain what the value of this
is in a normal function.
- The global ojbect.
I can explain what the value of this
is when called from the context of an object.
- The object in which it was called.
I can explain how to explicitly set the value of this
in a function.
- Using
call
we can set the value of this as the first argument. Or 'apply' takes an array of of the normal arguments.
I can explain the difference between call
and apply
.
-They both all this
to be set as the first argument, but all then takes a series of arguments, while apply takes an array.
I can describe an case where I might need to use bind
to avoid polluting the global scope.
- When making an AJAX call to get the desired data
I can explain how bind
works.
- Creates a new function where
this
is carried over. It's a way to pass the context ofthis
.