Skip to content
Related Articles

Related Articles

JavaScript SyntaxError – Missing formal parameter
  • Last Updated : 24 Jul, 2020

This JavaScript exception missing formal parameter occurs if any function declaration doesn’t have the valid parameters.

Message:

SyntaxError: missing formal parameter (Firefox)

Error Type:

SyntaxError

Cause of Error: The function declaration is missing the formal parameters.

Example 1: In this example, the parameter ‘num’ is not defined in the list of formal parameters, So the error has occurred.



HTML




<!DOCTYPE html>
<html>
<head>
    <title>Syntax Error</title>
</head>
<body>
    <script>
    function cube(5) {
      return num * num * num;
    }
    </script>
</body>
</html>

Output(In Firefox console):

SyntaxError: missing formal parameter

Example 2: In this example, the parameter ‘GeeksforGeeks’ is not defined in a list of formal parameters, So the error has occurred.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>Syntax Error</title>
</head>
<body>
    <script>
    function GFG("Geek") {
      return GeeksForGeeks;
    };
    </script>
</body>
</html>

Output(In Firefox console):

SyntaxError: missing formal parameter

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :