Firefox Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about logic error hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges how to fix syntax error Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Semantic Error
Join them; it only takes a minute: Sign up What is causing the syntax error I see in Firefox developer console? up vote 0 down vote favorite Attached is a screenshot of the developer console. I see a
Syntax Error In Programming
syntax error in a closure definition. I've a JavaScript file, which has the following function. I'm loading the JavaScript file from another function and calling sampleFunction() from it. var sampleFuntion=function(obj){ //Statement here; }; But Firefox shows a syntax error for the first line, which is the function declaration/definition. I'm using Mozilla Firefox 29.0.1 on Windows 7. What is the actual error in the code? javascript firefox firefox-developer-tools share|improve this question edited May 28 '14 at 20:31 Sebastian Zartner syntax error javascript 7,27832956 asked May 28 '14 at 6:37 Rupam Datta 1,17611230 It's really hard to read the code in the screen shot. Can you post it as plain text? –Barmar May 28 '14 at 6:42 @Barmar Just edited. Please check now. –Rupam Datta May 28 '14 at 6:47 There is no syntax error, there... Are there any illegal characters around that function that aren't rendering? –Cerbrus May 28 '14 at 6:54 @Cerbrus Yes I also feel the same. There is no syntactical error. Also I rechecked for any illegal characters. –Rupam Datta May 28 '14 at 7:04 So, exactly what error is the console throwing? –Cerbrus May 28 '14 at 7:12 | show 1 more comment 3 Answers 3 active oldest votes up vote 2 down vote As the indicated script line doesn't contain any visual syntactical error, the problem is probably either an invisible illegal character within that line like e.g. a zero-width space. In that case just rewrite your function and ensure you replace everything up to the beginning of the file. Or the line number is incorrectly displayed within the console and the error is actually somewhere else. To test that simply remove that function from the script and see whether there is still a syntax error displayed at line one afterwards. If so, you may remove other parts of
BMO. For more details see Persona Deprecated. Last Comment Bug1031985 - console
Math Error
reports syntax error for valid json fetched via jquery.ajax Summary: console static semantic error reports syntax error for valid json fetched via jquery.ajax Status: NEW Whiteboard: Keywords: Product: Firefox Classification: execution error Client Software Component: Developer Tools: Console (show other bugs) Version: Trunk Platform: x86 Mac OS X Importance: -- normal with 1 vote (vote) TargetMilestone: --- Assigned To: http://stackoverflow.com/questions/23904382/what-is-causing-the-syntax-error-i-see-in-firefox-developer-console Nobody; OK to take it and work on it QA Contact: TriageOwner: (Unavailable until Nov 1) Brian Grinstead [:bgrins] Mentors: URL: Depends on: Blocks: Show dependency tree /graph Reported: 2014-06-29 20:32 PDT by Mike Shaver (:shaver -- probably not reading bugmail closely) Modified: 2016-07-22 09:01 PDT (History) CC List: 8 users (show) https://bugzilla.mozilla.org/show_bug.cgi?id=1031985 adam.laycock andrew.filonov arliweng dchinniah kcchouette mihai.sucan miket peter.kehl See Also: Crash Signature: (edit) QA Whiteboard: Iteration: --- Points: --- Has Regression Range: --- Has STR: --- Tracking Flags: Attachments loadJsonFile.xul (981 bytes, application/vnd.mozilla.xul+xml) 2014-11-03 21:32 PST, Peter Kehl no flags Details aFile.txt (97 bytes, text/plain) 2014-11-03 21:33 PST, Peter Kehl no flags Details View All Add an attachment (proposed patch, testcase, etc.) Description Mike Shaver (:shaver -- probably not reading bugmail closely) 2014-06-29 20:32:07 PDT I have the following content a JSON file: ------ [ {"author": "Pete Hunt", "text": "This is one comment"}, {"author": "Jordan Walke", "text": "This is *another* comment, wow"} ] ------ When it's loaded via $ajax, I get an error in the console: syntax error comments.json:1 The file seems to be parsed correctly nonetheless, and JSON.parse from the console correctly decodes it. Chrome doesn't report an error here. Nightly of 6-27 vintage. Comment 1 Mihai Sucan [:msucan] 2014-07-22 03:26:14 PDT This sounds like a problem with $ajax. I
& Guides Learn the Web Tutorials References Developer Guides Accessibility Game development ...more docs Mozilla Docs Add-ons Firefox WebExtensions Developer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement ToolsFeedback Get Firefox help Get web development help Join the MDN community Report a content problem Report a bug Search Search Languages Deutsch (de) Français (fr) 日本語 (ja) Add a translation Edit Advanced Advanced History Print this article MDN Web technology For developers JavaScript JavaScript reference JavaScript error reference SyntaxError: missing ; before statement Your Search syntax error Results jwhitlock fscholz SyntaxError: missing ; before statement In This Article MessageError typeWhat went wrong?ExamplesUnescaped stringsDeclaring properties with varSee also Message SyntaxError: missing ; before statement Error type SyntaxError. What went wrong? There is a semicolon (;) missing somewhere. JavaScript statements must be terminated with semicolons. Some of them are affected by automatic semicolon insertion (ASI), but in firefox syntax error this case you need to provide a semicolon, so that JavaScript can parse the source code correctly. However, oftentimes, this error is only a consequence of another error, like not escaping strings properly, or using var wrongly. You might also have too many parenthesis somewhere. Carefully check the syntax when this error is thrown. Examples Unescaped strings This error can occur easily when not escaping strings properly and the JavaScript engine is expecting the end of your string already. For example: var foo = 'Tom's bar'; // SyntaxError: missing ; before statement You can use double quotes, or escape the apostrophe: var foo = "Tom's bar"; var foo = 'Tom\'s bar'; Declaring properties with var You cannot declare properties of an object or array with a var declaration. var obj = {}; var obj.foo = "hi"; // SyntaxError missing ; before statement var array = []; var array[0] = "there"; // SyntaxError missing ; before statement Instead, omit the var keyword: var obj = {}; obj.foo = "hi"; var array =