Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript SyntaxError – Missing ; before statement

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

This JavaScript exception missing ; before statement occurs if there is a semicolon (;) missing in the script.

Message:

SyntaxError: Expected ';' (Edge)
SyntaxError: missing ; before statement (Firefox)

Error Type:

SyntaxError

Cause of Error: Somewhere in the code, there is a missing semicolon (;). You need to provide it so that JavaScript can parse the source code without any error.

Example 1: In this example, the string is not escaped properly and JavaScript expecting a “;”, so the error has occurred.

Javascript




// invalid string
let GFG = 'This is GFG's platform'; 
console.log(GFG);

Output(In console of Edge Browser):

SyntaxError: Expected ';'

Example 2: In this example, the properties of an object is declared with the var declaration, Which is invalid. So the error has occurred, 

Javascript




let GFG = {};
let GFG.prop_1 = 'Val_1';
console.log(JSON.stringify(GFG));

Output(In console of Edge Browser): 

SyntaxError: Expected ';'
My Personal Notes arrow_drop_up
Last Updated : 22 May, 2023
Like Article
Save Article
Similar Reads
Related Tutorials