How to invoke a function without parenthesis using JavaScript ? Last Updated : 24 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Method 1: Using the new operator. The new operator is used to create an instance of an object which has a constructor function. This constructor function can be used to write our own function and then be invoked by the new operator. The parenthesis is optional when using this operator, hence the function would be invoked even without them. Syntax: new exampleFunction Example: html <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> How to invoke a function without parentheses? </b> <p class="output"></p> <script type="text/javascript"> function exampleFunction() { document.querySelector(".output").textContent = "The function was called!"; } // Using the new operator new exampleFunction; </script> </body> Output: Method 2: Using tagged template literals. Tagged template literals are a use case of template literals that was introduced in JavaScript ES6. It allows the use of functions directly when using template literals. It can be used with parameters bypassing them in the literals. To invoke a function, its name is written along with back-ticks (` `) to denote it as tagged template literals. Syntax: exampleFunction`` Example: html <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> How to invoke a function without parentheses? </b> <p class="output"></p> <script type="text/javascript"> function exampleFunction() { document.querySelector(".output").textContent = "The function was called!"; } // Using tagged template literals exampleFunction``; </script> </body> Output: Method 3: Modifying the toString() method. The toString() method is invoked whenever a string conversion is necessary. An object can be created which has the toString() method modified to call the required function. This object can be used to call toString() by performing a concatenation with an empty string. It will force the toString() method to be called which will in turn, invoke the specified function. Syntax: let tempObj = { toString: exampleFunction } '' + tempObj; Example: html <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> How to invoke a function without parentheses? </b> <p class="output"></p> <script type="text/javascript"> function exampleFunction() { document.querySelector(".output").textContent = "The function was called!"; } let tempObj = { toString: exampleFunction } // Forcing the modified // toString function to be invoked '' + tempObj; </script> </body> Output: Comment More infoAdvertise with us Next Article How to invoke a function without parenthesis using JavaScript ? S sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to convert a string into a integer without using parseInt() function in JavaScript ? In JavaScript, there is a simple function parseInt() to convert a string to an integer. In order to know more about the function, you can refer to this. In this article, we will learn how to convert the string to an integer without using the parseInt() function. Advantage of parseInt() over this met 3 min read How to write a function in JavaScript ? JavaScript functions serve as reusable blocks of code that can be called from anywhere within your application. They eliminate the need to repeat the same code, promoting code reusability and modularity. By breaking down a large program into smaller, manageable functions, programmers can enhance cod 4 min read How to transform String into a function in JavaScript ? In this article, we will see how to transform a String into a function in JavaScript. There are two ways to transform a String into a function in JavaScript. The first and easy one is eval() but it is not a secure method as it can run inside your application without permission hence more prone to th 3 min read How to call function from it name stored in a string using JavaScript ? In this article, we will call a function from the string stored in a variable. There are two methods to call a function from a string stored in a variable. Using window object methodUsing eval() method Note: The eval() method is older and is deprecated. Method 1: Using the window object. The window 2 min read Passing a function as a parameter in JavaScript In this article, we will pass a function as a parameter in JavaScript. Passing a function as an argument to the function is quite similar to passing a variable as an argument to the function. So variables can be returned from a function. The below examples describe passing a function as a parameter 1 min read Like