Created
October 27, 2013 21:18
-
-
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/
This file contains hidden or 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
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