Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels