Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Created May 7, 2018 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colevandersWands/6a84d2ce03414456d1d57960d29b8ca0 to your computer and use it in GitHub Desktop.
Save colevandersWands/6a84d2ce03414456d1d57960d29b8ca0 to your computer and use it in GitHub Desktop.
call, bind & constructors. "this" is strange
function learning_context(arg) {
console.log(arg)
console.log(this.prop)
}
let bound_context = {
prop: "bound"
}
let call_context = {
prop: "call"
}
// learning_context("flying solo")
learning_context.call(call_context, "called arg")
let bound_learning = learning_context.bind(bound_context);
bound_learning("bound arg")
// let's make "this" work
new learning_context("constructored arg")
// https://goo.gl/WPSBJ6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment