ES15 has introduced Records and Tuples, So can we use array as a attribute value inside the Record? Can we use object as a value of Tuple index?
1. Is it a valid for Record ?
const user = #{
name: "Avyukt",
age: 39,
hobbies: ['sleeping', 'eating', 'crying'] // Is it a valid add arr
}
2. Is it a valid Tuple?
const user = #[
{ name: "Avyukt", age: 1 }, // Is it valid to add object as a value
{ name: 'Reyansh', age: 5 }
]
This part of the proposed specification:
https://github.com/tc39/proposal-record-tuple/blob/5c9a6e144c687ef5911f4c0c088bc21343cbaf68/README.md?plain=1#L252
No, a tuple may not contain an object, but it can contain a Record, in the current proposal
Likewise, a record may not contain an array value, but it can contain a tuple.
I would caution against the title that ES15 has introduced anything.
This is currently a stage 2 proposal only.