DEV Community

Performance of optional chaining

Eryk Napierała on November 07, 2019

One of the coolest features added in just announced TypeScript 3.7 is optional chaining syntax. It promises a much shorter and more readable code f...
Collapse
 
xstevenyung profile image
Steven Yung

Really interesting take on this. I never thought about performance but it’s quite some insight that you provided there. Thanks for sharing 👍

Collapse
 
mauddibb profile image
MaudDibb

had a little fun with that dlv function:

const dlv=(o,k,d,u)=>(k.split?k.split('.'):k).reduce((r,v)=>(o=r?r[v]:u,o),o)===u?d:o;

Collapse
 
erykpiast profile image
Eryk Napierała

Nice! Did you test, how fast is it? :D