JavaScript SyntaxError – Missing formal parameter

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output(In Firefox console):

SyntaxError: missing formal parameter

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.