Closed uncenter closed 6 days ago
Internally, the function to convert a value to iterator (that will be used then in the for
) use Object.entries
to get the key and value of an array: https://github.com/ventojs/vento/blob/main/plugins/for.ts#L61-L63
The keys are always returned as strings. For example:
Object.entries([1, 2, 3])
// [ "0", 1 ], [ "1", 2 ], [ "2", 3 ] ]
This is not what most people would expect, so I'm going to fix it.
fixed in v1.12.12
Instead of Object.entries(item).map(([key, value]) => [parseInt(key, 10), value])
you should just be able to do item.map((value, index) => [index, value])
.
@uncenter You're absolutely right. I can't belive I missed that 🤦
I'm struggling to understand why this equality check is different between the
==
and===
in the following snippet:🔗 Playground
The output of the above is:
As you can see on the last line for C, the double equals (
==
) compares2
and2
and evaluates to true, wheres the triple equals (===
) compares the same2
and2
and evaluates to false.