Skip to content

Instantly share code, notes, and snippets.

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

JavaScript Functions

I can explain the difference between function declarations and function expressions. Yes. Declarations can get used higher than they are written, expressions can't.

I can explain what the value of this is in a normal function. Global window

I can explain what the value of this is when called from the context of an object. The object

I can explain how to explicitly set the value of this in a function. .call(this, arguments) or .apply(this, [arguments])

I can explain the difference between call and apply. They allow you to explicitly define this, the only difference is that aaply takes other arguments as an array whereas call doesn't need the arguments to be in an array.

I can describe an case where I might need to use bind to avoid polluting the global scope. Yes, when something is asyn, or calling a function from a constructor, you may need to bind the 'this'

I can explain how bind works. Passing a function and the context of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment