如何修复 Javascript 中缺少的分号语法错误? [英] How do I fix this missing semicolon syntax error in Javascript?

查看:30
本文介绍了如何修复 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: Expected ';'.我没有看到任何地方缺少分号,而且我无法想象它想让我把分号放在哪里.

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 imagine where it wants me to put one.

它在哪里需要分号,为什么需要分号?

Where does it expect a semicolon and why does it expect a semicolon there?

推荐答案

你的问题是函数中的 i 是 unicode 字符 i.如果您将其更改为正常"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.

但现在我想知道 hack 是如何实现的 :) 你在那里得到了一个 unicode 字符 :P

But now I'm wondering how the hack :) did you get an unicode character there :P

这篇关于如何修复 Javascript 中缺少的分号语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆