semicolon after function

Semicolons after function declarations are not necessary.

The grammar of a FunctionDeclaration is described in the specification as this:

function Identifier ( FormalParameterListopt ) { FunctionBody }

There’s no semicolon grammatically required, but might wonder why?

Semicolons serve to separate statements from each other, and a FunctionDeclaration is not a statement.

This entry was posted in JavaScript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s