-
@Raik, is the above code in one monolithic file, as the modules file, or is there a calling page?
It's the piece of code from the editor I upload to experiment with modules. Later on this will be put to the file system as one file (that's the plan).
It's possible that L21 needs to also pass 'freq' 'time' as arguments
Well it's referring to the beep function, that only has two argument. So it should work, right?
change this. to SOUND. in line 21.
or add ‘that’Thanks for the hint: creating a new reference for this worked, though I'm not sure why?
Is it because the module code runs in its own scope? And this is not referring to SOUND but rather to the main scope?
When a module is loaded, Espruino executes the file in its own scope
(from Writing Modules)
-
It's "just classic javascript
this
" :) It's not a because "the module code runs in its own scope".
At line 21, thethis
inside the callback function inside thesetInterval
is not what you would expect. Basically nothing / global scope, because you did not specify thethis
argument, or usedbind
. Just JS default behavior. :)
That's why code was littered withvar that = this
. But now it's kind-of sort-of solved in ES6 / typescript code.
This is about object reference.
change this. to SOUND. in line 21.
or add ‘that’