Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created December 31, 2013 06:28
Show Gist options
  • Save lyuehh/8193356 to your computer and use it in GitHub Desktop.
Save lyuehh/8193356 to your computer and use it in GitHub Desktop.
var User = {
count: 1,
getCount: function() {
return this.count;
}
};
console.log(User.getCount());
var func = User.getCount;
console.log(func());
var func2 = User.getCount.bind(User);
console.log(func2());
Function.prototype.bind = Function.prototype.bind || function (context) {
var that = this;
return function() {
that.apply(context, arguments);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment