Created
November 1, 2017 03:39
-
-
Save limabeans/6c7c092ed5d230555c087787f768db5b to your computer and use it in GitHub Desktop.
bind in js
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
var a=2; | |
var obj={a: 3}; | |
function getA() { return this.a; } | |
console.log(getA()); // 2 | |
var tmp=getA.bind(obj); | |
console.log(tmp()); // 3 | |
// https://stackoverflow.com/questions/5490448/how-do-i-pass-the-this-context-into-an-event-handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment