Skip to content

Instantly share code, notes, and snippets.

@SteveOscar
Forked from stevekinney/1510-function-cfus.md
Last active March 30, 2016 17:31
Show Gist options
  • Save SteveOscar/4377d9e359373284f23d83b8165d68ab to your computer and use it in GitHub Desktop.
Save SteveOscar/4377d9e359373284f23d83b8165d68ab to your computer and use it in GitHub Desktop.

JavaScript Functions

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 of this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment