I was referring to this link: Future Javascript: Records and Tuples and I was wondering, what is the reasoning behind these?
We can still use Object.freeze with both arrays and objects to achieve this. Only reasoning I can think of is compare by value. So this will allow us to have complex object like structure(records) in Set as keys and we can fetch them without much hassle. But does this look big enough reason to add new datatype in a language?
Object.freezeprotects writing access just at an object's first (entry/property) level. Any structure nested deeper than 1 is writable. Thus a frozen object never is deeply frozen.In order to achieve the latter one has to write ones' own recursive
deepFreezefunction.In contrast the future primitive
RecordandTuplevalues are truly/entirely immutable.