The Invocation () Operator
Definition
When placed after a function name, () is the Invocation (Function Call) operator.
It executes the function and holds any arguments being passed to it.
Example
console.log(); // Invokes the log function
myFunction(); // Calls myFunction
Not Always Invocation
Parentheses are also used in other parts of the JavaScript syntax (not only function invocation):
- Expression grouping:
(x + y) * y - Wrapping if conditions:
if (age > 18) - Controlling loops:
for (let i = 0; i < 10; i++)
Browser Support
() is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera |