JavaScript .js 文件的第 1 行出现意外的输入错误结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20234000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 18:03:38  来源:igfitidea点击:

Unexpected end of input error in line 1 of JavaScript .js file

javascriptinputgoogle-chrome-devtools

提问by user3040145

Chrome Dev Tools throws the following JavaScript error:
Uncaught SyntaxError: Unexpected end of input ... application.js:1

Chrome Dev Tools 抛出以下 JavaScript 错误:
Uncaught SyntaxError: Unexpected end of input ... application.js:1

application.js file (first two lines):

application.js 文件(前两行):

var firstTimeExecuting = true;   //should execute only once...above function call.
function guessAnal(guess) { ...  //Analyze the guess.     

回答by jm0

Often times a line 1 error indicates that there is a major syntax error in the script somewhere that is preventing it from parsing correctly. Ignore the line number and carefully check your whole js script. If you're really having issues try breaking it into several js files, that way you can see which is failing (a syntax error in a js script causes that entire script to be ignored).

通常,第 1 行错误表示脚本中某处存在严重的语法错误,导致无法正确解析。忽略行号并仔细检查整个 js 脚本。如果您确实遇到问题,请尝试将其分解为多个 js 文件,这样您就可以看到哪个失败了(js 脚本中的语法错误会导致整个脚本被忽略)。