Yes - in JavaScript, the only real difference between executing a method call and a normal function is what this is set to.
So, if you define the variable ph in a function, it just stays in that function - but it's nothing to do with the class at all. To actually access the class, you have to explicitly use this..
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.
Yes - in JavaScript, the only real difference between executing a method call and a normal function is what
this
is set to.So, if you define the variable
ph
in a function, it just stays in that function - but it's nothing to do with the class at all. To actually access the class, you have to explicitly usethis.
.