function test(){
var interval;
console.log(this);
this.a = 0;
interval = setInterval(function(){
this.a++;console.log(this,this.a);
},2000);
}
var b = new test();
and compare, it looks like this is handled fine. The issue is that undefined+1 (and hence this.a++) returns NaN in other JS implementations, but in Espruino it just returns 1. I'll make a bug for that, and also for a++ errors so at least we can track it.
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.
Just to add, if you do:
and compare, it looks like
this
is handled fine. The issue is thatundefined+1
(and hencethis.a++
) returnsNaN
in other JS implementations, but in Espruino it just returns1
. I'll make a bug for that, and also fora++
errors so at least we can track it.bugs:
https://github.com/espruino/Espruino/issues/146
https://github.com/espruino/Espruino/issues/147