Here's working code sample:
function Drum(){
this.noise = 'boom';
this.duration = 1000;
this.goBoom = function(){console.log(this.noise)};
}
var drum = new Drum();
setInterval(drum.goBoom.bind(drum), drum.duration);
If I remove .bind(drum)
part from this code instead of 'boom' I'll get 'undefined' in console.
What's the reason of such behavior since typeof drum.goBoom
returns 'function' ?