You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I would like to confirm some assumptions about Records. I think they should be added to the .md file for more clarity.
records will work with subscripts the same way as objects do
const a = #{a: 1}
a.a === 1
a['a'] === 1
Object.assign will work for records as well.
const b = Object.assign(#{}, {a: 1}, {b: 2}, #{b: 3})
b === #{a: 1, b: 3}
Values in a record can still be functions and other non-value types.
The only way to convert a record to an Object would be to use Object.assign
Some questions:
Is there no way of adding or updating a key on a record? With objects you can just set a new value. That seems impossible with records, but potentially very useful.
Will other class methods on Object also work on records? Object.keys for example?
Object is javascript are currently ordered in all major implementations. Will records also be ordered maps in this way?
What is the value of keeping separate types for record and ImmutableMap? Perhaps it's a better idea to combine the two into a single type. It would be called ImmutableMap, but it would actually be an orderedMap, just like javascript Object is practice.
The text was updated successfully, but these errors were encountered:
I'm not sure if Object.assign should work if a record is the first argument. If it's one of the rest arguments, absolutely, but since Object.assign is expected to mutate the first argument, it seems strange that it would work on an immutable record.
First, I would like to confirm some assumptions about Records. I think they should be added to the .md file for more clarity.
Some questions:
Object.keys
for example?The text was updated successfully, but these errors were encountered: