proposal-extensions icon indicating copy to clipboard operation
proposal-extensions copied to clipboard

Optional chaining for extensions -- `?::`

Open andyearnshaw opened this issue 1 year ago • 4 comments

It would be great if optional chaining was baked into the proposal:

document.querySelector("#myElement")?::let(it => {
  // it's safe to do things with the element here
  setupInteractivity(it);
});

Equivalent to:

let temp = document.querySelector("#myElement");
if (temp != null) {
    setupInteractivity(temp);
}

andyearnshaw avatar Sep 26 '24 13:09 andyearnshaw