Skip to content

Instantly share code, notes, and snippets.

@mateuszkocz
Created October 27, 2013 21:18
Show Gist options
  • Save mateuszkocz/7188001 to your computer and use it in GitHub Desktop.
Save mateuszkocz/7188001 to your computer and use it in GitHub Desktop.
Bind with anonymous function. Source: http://dailyjs.com/2012/06/25/this-binding/
Shape.prototype = {
move: function(x, y) {
this.x += x;
this.y += y;
var checkBounds = function(min, max) {
if (this.x < min || this.x > max) {
console.error('Warning: Shape out of bounds');
}
}.bind(this);
checkBounds(0, 100);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment