I'm trying to use _.throttle
in an object but I think I haven't understand how to do this correctly.
I use jQuery and Underscore.js
function object() {
this.throtthled = function () {
// This should alert 1
alert(this.var);
}
this.fastFunc = _.throttle(this.throtthled, 100);
this.var = 1;
}
$(function () {
var myObject = new object();
$(document).on('mousemove', myObject.fastFunc);
});
But as you can see on this jsfiddle, this only returns undefined
in console.
What am I doing wrong ?