Hi everyone,
consider the following example:
const myObj = {
propertyOne: 'someValue',
propertyTwo: 'another value',
};
suppose I have to get a non existing property dynamically with a
fallback on another one:
let myProp = myObj['propertyTwo'];
if (myObj['propertyThree']) {
myProp = myObj['propertyThree'];
}
wouldn't it be nice to have a quicker way of doing that like this?
const myProp = myObj['propertyThree' || 'propertyTwo'];
this will return undefined of course but some other operator could be used like:
let myProp = myObj['propertyThree' ?? 'propertyTwo'];
let myProp = myObj['propertyThree' ?? 'propertyFour' ?? 'propertyTwo'];
any thoughts?
cheers,
Serghei
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss