TIL this is valid #JavaScript: onClick?.(); I'm familiar with optional...


TIL this is valid #JavaScript:

onClick?.();

I'm familiar with optional chaining, but I didn't realize I could use it before the invocation parens like this. :)

So this says "If onClick is defined, invoke it."

h/t to @donavon

View original on X