How do I fix this missing semicolon syntax error in Javascript?

前端 未结 6 2028
说谎
说谎 2020-12-08 02:24

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 rep

6条回答
  •  难免孤独
    2020-12-08 03:02

    In fact, you inserted unicode "i" instead of normal "i". I get the fellow errors in VSCode:
    ',' expected. (1, 29)
    ',' expected. (2, 10)
    Declaration or statement expected. (4, 3)
    You can try evaluating "functіon" == "function" as well:

    function compare() {
      return "functіon" === "function"
    }
    console.log(compare())

    However, when I try to compare it by drawing "function" myself: it returns true;

    function compare2() {
      return "function" == "function"
    }
    console.log(compare2())

    Also, I didn't include semicolons here, in javascript they aren't necessary.

提交回复
热议问题