admin管理员组文章数量:1026989
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]
}
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.
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]
}
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.
Share Improve this question asked Mar 16, 2016 at 20:10 CalrocksCalrocks 651 gold badge4 silver badges11 bronze badges 2-
eachItem
is not an array. Somewhere you assigned a wrong value to it. It seems you assigned a function instead of calling it. Of course without a plete example, there is nothing we can do. Please read minimal reproducible example. – Felix Kling Commented Mar 16, 2016 at 20:15 - Hmm. That would make sense. Here is a jsfiddle with the full code: jsfiddle/adibb/m0stnb7z/1 – Calrocks Commented Mar 16, 2016 at 20:24
3 Answers
Reset to default 4Internet Explorer (11) has a global function called item
which is read only. After item="foo"
, item.toString()
still shows
function item() {
[native code]
}
However it can be redeclared. After var item = foo
, item.toString()
shows
`foo`
Looking for use of item
in the fiddle code finds
item = serviceTitleRow + eachService + trip_charge;
at line 98 without previous declaration. I suggest declaring item
before use will likely fix the problem.
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.
Review your code to find if there is any variable that has not been declared and you are using that directly. For Example:
- abc={} may cause issue in IE
- var abc={} will work
I had a variable that was not defined with the var keyword. Solved my issue.
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]
}
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.
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]
}
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.
Share Improve this question asked Mar 16, 2016 at 20:10 CalrocksCalrocks 651 gold badge4 silver badges11 bronze badges 2-
eachItem
is not an array. Somewhere you assigned a wrong value to it. It seems you assigned a function instead of calling it. Of course without a plete example, there is nothing we can do. Please read minimal reproducible example. – Felix Kling Commented Mar 16, 2016 at 20:15 - Hmm. That would make sense. Here is a jsfiddle with the full code: jsfiddle/adibb/m0stnb7z/1 – Calrocks Commented Mar 16, 2016 at 20:24
3 Answers
Reset to default 4Internet Explorer (11) has a global function called item
which is read only. After item="foo"
, item.toString()
still shows
function item() {
[native code]
}
However it can be redeclared. After var item = foo
, item.toString()
shows
`foo`
Looking for use of item
in the fiddle code finds
item = serviceTitleRow + eachService + trip_charge;
at line 98 without previous declaration. I suggest declaring item
before use will likely fix the problem.
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.
Review your code to find if there is any variable that has not been declared and you are using that directly. For Example:
- abc={} may cause issue in IE
- var abc={} will work
I had a variable that was not defined with the var keyword. Solved my issue.
本文标签: javascriptconsolelog of Array returns function item()native codein IE 1011Stack Overflow
版权声明:本文标题:javascript - console.log of Array returns function item() { [native code] } in IE 10,11 - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745536930a2155003.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论