Home  >  Article  >  Web Front-end  >  What does function literal mean in JavaScript?

What does function literal mean in JavaScript?

WBOY
WBOYforward
2023-09-05 12:17:041183browse

What does function literal mean in JavaScript?

A function literal is an expression that defines an unnamed function. You can try running the following code to implement function literals in JavaScript.

Example

<html>
   <head>
      <script>
         <!--
            var func = function(x,y){ return x*y };

            function secondFunction() {
               var result;
               result = func(10,20);
               document.write ( result );
            }
         //-->
      </script>
   </head>
   <body>
      <p>Click the following button to call the function</p>

      <form>
         <input type = "button" onclick = "secondFunction()" value = "Call Function">
      </form>
   </body>
</html>

The above is the detailed content of What does function literal mean in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete