The difference is that you are not passing the id in as an argument to setInterval, but are defining it in a function that the callback (the function inside setInterval) has access to.
In it's simplest form, not this:
var idAnim;
function f(){
idAnim = setInterval(function(id){
clearInterval(id);
}, 100, idAnim);
}
but this:
function f(){
var idAnim = setInterval(function(){
clearInterval(idAnim);
}, 100);
}
I'm not quite sure what you're trying to do, but try starting with the code above and then modifying it to do what you want.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The difference is that you are not passing the
id
in as an argument to setInterval, but are defining it in a function that the callback (the function inside setInterval) has access to.In it's simplest form, not this:
but this:
I'm not quite sure what you're trying to do, but try starting with the code above and then modifying it to do what you want.