In JavaScript, I would like to create persistent immutable collections from object initializers, such as arrays and maps, to make such collections more readable. It is possible to use get functions:
Object.defineProperty(Object.prototype, 'i', { get: function() {
...code to convert map to immutable map...
} });
let b = {name:"John Doe", age: 34}.i;
But is it possible to change the construct methods, used by the object initializers for Object and Array, to make them create immutable versions?