Skip to content

Instantly share code, notes, and snippets.

@nicolo-ribaudo
Last active June 23, 2023 17:44
Show Gist options
  • Save nicolo-ribaudo/d264e424b618e7deaeca1d6e4f16a7c0 to your computer and use it in GitHub Desktop.
Save nicolo-ribaudo/d264e424b618e7deaeca1d6e4f16a7c0 to your computer and use it in GitHub Desktop.

Optional chaining assignment proposal

Basically, allow this:

foo?.bar = value;

which is equivalent to

foo == null ? undefined : (foo.bar = value);

Real-world examples

Use this regexp to find some of them in your codebase: if \((.*?)\)[\s\n]*\{?[\s\n]*\1\.

Babel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment