Thanks both for the quick and attentive responses.
I thought I'd found the culprit. I mistakenly used tb.setX = 42; when as @Gordon pointed out should use tb.setX(42);
Note line #6 that shows the class contents aren't getting updated
But when I run that tb.setX(42);, I'm faced with yet another error:
>var tb = new TestBind();
=TestBind: { "vX": 25 }
=25
>tb.setX = 42;
=42
>print tb.getX();
=25
>var bg = g.bind(tb);
Uncaught Error: Function "bind" not found!
at line 1 col 12
var bg = g.bind(tb);
^
>print bg
=undefined
>tb.setX(42);
Uncaught Error: Expecting a function to call, got Number
at line 1 col 4
tb.setX(42);
^
>
This is why I originally used the syntax tb.setX = 42; to avoid the 'Expecting a function to call' error
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.
Tue 2018.09.18
Thanks both for the quick and attentive responses.
I thought I'd found the culprit. I mistakenly used
tb.setX = 42;
when as @Gordon pointed out should usetb.setX(42);
But when I run that
tb.setX(42);
, I'm faced with yet another error:This is why I originally used the syntax
tb.setX = 42;
to avoid the 'Expecting a function to call' error