Closed philipandresen closed 1 year ago
Thanks! That's super helpful.
A change went in recently to ensure that Object.keys
/etc always returned array indexes as strings to be spec compliant, and I bet that broke this. Hopefully quite an easy fix though...
I'm not sure about the theoretical minimal reproduction case but this is the best I have:
Espruino Web IDE - Left hand side: Enter:
Object.entries({"1": "Hello"})
Expected result:[ [ "1", "Hello" ] ]
Actual result:[ [ "1", undefined ] ]
Enter:
Object.values({"1": "Hello"})
Expected result:[ "Hello" ]
Actual result:[ undefined ]
By contrast if you do these tests with an object containing "1a" as a key, it works as expected. That would be a reasonable workaround in some cases. Another workaround would be using Object.keys (which works fine) and then programmatically accessing the object within a loop, which is what I'll probably do for now.
Use case: Using an object as a map where the key is a numeric ID.
Suspected root cause: https://github.com/espruino/Espruino/commit/ae664896d01716aef6b035d16eac4ccbee59a254
I would normally try to submit a fix, but I am super shaky on C and am pretty new to Espruino and javascript interpreters in general. If I can work it out I would be happy to open a PR but it's a little over my head at the moment.