Skip to content

Instantly share code, notes, and snippets.

@limabeans
Created November 1, 2017 03:39
Show Gist options
  • Save limabeans/6c7c092ed5d230555c087787f768db5b to your computer and use it in GitHub Desktop.
Save limabeans/6c7c092ed5d230555c087787f768db5b to your computer and use it in GitHub Desktop.
bind in js
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