Array的console.log在IE 10,11中返回函数item(){[native code]} [英] console.log of Array returns function item() { [native code] } in IE 10,11

查看:225
本文介绍了Array的console.log在IE 10,11中返回函数item(){[native code]}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试IE ajax问题。我收集并存储在数组中的数据称为eachItem。然后使用eachItem.join(’)将其转换为字符串。但是在执行此步骤之前,我先进行console.log数组,然后IE 10和11返回

I am trying to debug an IE ajax issue. The data I collect in and store in an array call eachItem. It is then converted to a string using eachItem.join(''). But before it even makes it to this step I console.log the array and IE 10 and 11 return

 function item() {
   [native code]
 }

eachItem.length的console.log返回1。但是我看不到内容。稍后,我通过ajax推送此数据,并得到一个空数组。但是我试图首先从这里开始,以了解为什么IE似乎无法读取我的数组。

A console.log of eachItem.length returns 1. But I can't see the contents. I later am pushing this data over ajax and getting an empty array. But I was trying to start here first to see why IE doesn't seem to read my array.

推荐答案

Internet Explorer(11)具有一个名为 item 的全局函数。是只读的。在 item = foo 之后, item.toString()仍然显示

Internet Explorer (11) has a global function called item which is read only. After item="foo", item.toString() still shows

function item() {
    [native code]
} 

但是可以重新声明。在 var item = foo 之后, item.toString()显示

However it can be redeclared. After var item = foo, item.toString() shows

`foo`

使用<$小提琴代码中的c $ c> item 找到

item = serviceTitleRow + eachService + trip_charge;

在第98行,而无需事先声明。我建议在使用前声明 item 可能会解决此问题。

at line 98 without previous declaration. I suggest declaring item before use will likely fix the problem.

FWIW ,Javascript严格模式将对未声明变量的赋值视为错误,并在大多数情况下捕获此错误。由于函数名称标识符没有用于变量标识符的单独名称空间,因此允许重新分配函数名称的值。但是,IE中的严格模式在尝试更新 item 的值时会引发不同的分配只读属性错误,因此严格模式可能有助于捕获此错误。

FWIW, Javascript strict mode treats assignment to an undeclared variable as an error and catches this error most of the time. Because function name identifiers don't have a separated name space to variable identifers, reassigning the value of a function name is allowed. However, strict mode in IE throws a different "assignment to read only property not allowed" error when trying to update the value of item, so strict mode may have helped catch this error earlier in multiple browsers.

这篇关于Array的console.log在IE 10,11中返回函数item(){[native code]}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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