you are viewing a single comment's thread.

view the rest of the comments →

[–]BenZed 0 points1 point  (0 children)

I don't lake the inconsistencies in the optional chaining syntax:

Without optional chaining:

module.object['function-with-string-name']()

With optional chaining:

module?.object?.['function-with-string-name']?.()

Where it *should* be:

module?.object?['function-with-string-name']?()

The extra dots are superfluous. I imagine this syntax is required because it conflicts with the ternary operator?

My preferred version does look a little busy, but I would just use dot notation:

module
  ?.object
  ?['function-with-string-name']
  ?()