All of you must know about typescript's/ECMA2020 new feature optional chaining.out of curiosity i was looking for the implementation methodology in typscript playground
And i was Expecting implementation of
let obj = {
name: {
age: {
what: {
x:12
}
}
}
}
console.log(obj?.name?.age?.what?.x);
this would be something like this in es6/7/8
console.log(obj&&obj.name&&obj.name.age&&obj.name.age.what&&obj.name.age.what.x)
But it looks something like this.
console.log((_c = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.name) === null || _a === void 0 ? void 0 : _a.age) === null || _b === void 0 ? void 0 : _b.what) === null || _c === void 0 ? void 0 : _c.x);
Can someone explain the advantage of doing something which normal people don't understand at first glance is used than the one i expected