Since we now have the "Optional Chaninig Operator" , perhaps a "Forced
Chaining Operator" would also be worth considering.
I, personally, could use it:
let table;
table!.user!.id!.type = 'int'
will evaluate to:
let table;
if ( ! ( table instanceOf Object) ) table = {};
if ( ! ( table.user instanceOf Object) ) table.user = {};
if ( ! ( table.user.id instanceOf Object) ) table.user.id = {};
table.user.id.type = 'int';
Also to be noted:
Sometimes a fallback to `Object.create(null)` or something other might be
desirable.
But since `{}` is syntactical sugar for `Object.create(Object.prototype)`,
this would be consistent.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss