[英]Whenever I try to compile javascript code I get a syntax error
Whenever I try to run my code I keep getting a syntax error the specifics of the error are here: https://i.stack.imgur.com/H73LR.png每当我尝试运行我的代码时,我都会收到语法错误,错误的细节在这里: https://i.stack.imgur.com/H73LR.png
I don't think it has to do anything with the file format because it is in a.js file I also ran a我认为它与文件格式没有任何关系,因为它位于 a.js 文件中,我还运行了一个
antivirus to see if that was causing it( a site online said viruses could cause this error) my code is as follows:杀毒软件看看是否是导致它(在线网站说病毒可能导致此错误)我的代码如下:
const firstName = 'William';
const lastname = 'Johnson';
let val;
val = firstName + lastname;
console.log(val)```
Your code looks fine, so I think it's your antivirus causing this problem.您的代码看起来不错,所以我认为是您的防病毒软件导致了这个问题。 Try disabling your antivirus and run your code again.
尝试禁用您的防病毒软件并再次运行您的代码。
The image seems you're trying to look up the .js
file directly from your browser.该图像似乎您正在尝试直接从浏览器中查找
.js
文件。
You can't look up a .js
file directly from your browser, the browser can't parse it.您无法直接从浏览器中查找
.js
文件,浏览器无法解析它。
You should create an HTML file ie a .html
file and link your script to it.您应该创建一个HTML文件,即
.html
文件并将您的脚本链接到它。
Eg In your HTML file例如在您的 HTML 文件中
<!Doctype html>
<html>
<head>
<script src="your script source.js"></script>
</head>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.