Skip to content

JS objects that have number keys do not associate properly with values #69

@KonSola5

Description

@KonSola5

If a JS object contains keys that are numbers or are strings that can be coerced to numbers, the value is not properly associated with that number key.

Reproduction:

const obj = { 0: 50, 1: 25, 2: 18, 3: 7 }

console.log(Object.keys(obj))
console.log(Object.values(obj))
console.log(Object.entries(obj))

Object.keys(obj) logs:

0
1
2
3

Object.values(obj) logs:

dev.latvian.mods.rhino.UniqueTag@2115b5b6: NOT_FOUND [dev.latvian.mods.rhino.UniqueTag]
dev.latvian.mods.rhino.UniqueTag@2115b5b6: NOT_FOUND [dev.latvian.mods.rhino.UniqueTag]
dev.latvian.mods.rhino.UniqueTag@2115b5b6: NOT_FOUND [dev.latvian.mods.rhino.UniqueTag]
dev.latvian.mods.rhino.UniqueTag@2115b5b6: NOT_FOUND [dev.latvian.mods.rhino.UniqueTag]

Object.entries(obj) logs:

[0, null]
[1, null]
[2, null]
[3, null]

What should happen is that number keys should be properly associated with their values.
Tested on KubeJS for Minecraft 1.20.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions