Saturday, November 15, 2025
HomeLanguagesJavascriptJavaScript SyntaxError – Missing ; before statement

JavaScript SyntaxError – Missing ; before statement

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 ';'
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS