Imagine a scenario where the following object exists:
function Foo(value){
this.bar = value;
this.update();
}
Foo.prototype.update = function(){
console.log(this.bar);
this.bar++;
requestAnimationFrame(this.update);
}
Foo.prototype.setBar(value){
this.bar = value;
}
An issue arises, as FireFox presents an error:
NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMWindow.requestAnimationFrame]
I am seeking insight into why this error occurs and potential alternative approaches to invoke an object's update method without direct invocation within the main function (i.e., while maintaining the object's anonymity).