Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一些老版本的脚本引擎在解析下面的代码时会出问题, #19

Open
maolion opened this issue May 1, 2015 · 1 comment

Comments

@maolion
Copy link

maolion commented May 1, 2015

var indexOf = Array.prototype.indexOf ?
    function(arr, item) {
      return arr.indexOf(item)
    } :
    function(arr, item) {
      for (var i = 0, len = arr.length; i < len; i++) {
        if (arr[i] === item) {
          return i
        }
      }
      return -1
    }

解析 函数表达 式 和 解析 函数 定义问题, 上面的一个函数 会被看做函数 定义被解析。因此碰到一个没有函数名的函数 定义会报错。。所以得加个括号包起来, 或换下方式?

@army8735
Copy link
Member

army8735 commented May 1, 2015

哪个浏览器?这条件表达式语法没问题的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants