如何在Javascript中修复此缺少的分号语法错误? [英] How do I fix this missing semicolon syntax error in Javascript?
问题描述
一位朋友为我写了一些代码,并且有一个文件中有一个奇怪的语法错误。经过一段时间的搜索,我把它缩小到这部分代码,它应该重现错误:
A friend wrote some code for me, and there was one file with a weird syntax error in it. After a bit of hunting, I narrowed it down to this section of code, which should reproduce the error:
var say = functіon(message) {
alert(message);
return message;
};
say(say("Goodbye!"));
当我运行此操作时,我在Internet Explorer控制台中看到一条错误 SCRIPT1004:预期';'
。我没有看到任何地方丢失分号,我无法想象我想要放一个分号。
When I run this, I see an error in the Internet Explorer console that says SCRIPT1004: Expected ';'
. I don't see a semicolon missing anywhere, and I can't image where it wants me to put one.
它在哪里可以看到分号,为什么会出现分号那里有分号?
Where does it expect a semicolon and why does it expect a semicolon there?
推荐答案
你的问题是 i
in function是unicode字符 i
。如果你将它改为'正常'我
它应该可以正常工作。
Your issue is the fact that the i
in function is the unicode character i
. If you change it to a 'normal' i
it should just work.
但现在我想知道如何黑客:)你在那里得到一个unicode角色:P
But now I'm wondering how the hack :) did you get an unicode character there :P
这篇关于如何在Javascript中修复此缺少的分号语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!