Created
May 7, 2018 09:32
-
-
Save colevandersWands/6a84d2ce03414456d1d57960d29b8ca0 to your computer and use it in GitHub Desktop.
call, bind & constructors. "this" is strange
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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