05-20-2020 16:32
05-20-2020 16:32
Given this array:
const FIB_SEQ = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89];
shouldn't this work?
const found = FIB_SEQ.find((element) => element > 45);
The error I'm getting is "App: Unhandled exception: TypeError: Expected a function."
I tested this in a code playground and it works as expected there. Is there some limitation in the FitBit implementation of JS? I feel like I'm missing something very simple here... having the same problem with array.indexOf as well.
05-20-2020 16:53
05-20-2020 16:53
On the watch, you have to limit yourself to ES5.1 (mostly).
05-21-2020 05:37
05-21-2020 05:37
Ah, okay. Thank you!
You said, "mostly..." Is there a guide to what is/isn't actually available?
05-21-2020 13:42
05-21-2020 13:42
I don't know of any reference on that, although it would be good to have.
There is some support for async/await and fetch.
05-21-2020 21:11
05-21-2020 21:11
@Gondwana wrote:I don't know of any reference on that, although it would be good to have.
There is some support for async/await and fetch.
Yes, mostly I just try it. They've actually implemented more than they've documented, though there are some idiosyncrasies.
On a positive note, if the results seem weird there's usually some information in the SDK forum about it.
05-25-2020 01:50
05-25-2020 01:50
Just to point some official documentation:
https://dev.fitbit.com/build/guides/application/#javascript
There it says it's ES5, with the JerryScript engine https://github.com/jerryscript-project/jerryscript
As you noticed there are also some additions like Promises