0

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.

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 complete example, there is nothing we can do. Please read minimal reproducible example. Commented Mar 16, 2016 at 20:15
  • Hmm. That would make sense. Here is a jsfiddle with the full code: jsfiddle.net/adibb/m0stnb7z/1 Commented Mar 16, 2016 at 20:24

3 Answers 3

4

Internet 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.

Sign up to request clarification or add additional context in comments.

1 Comment

microsoft still doesn't get that such behaviours will kill them
1

Review your code to find if there is any variable that has not been declared and you are using that directly. For Example:

  1. abc={} may cause issue in IE
  2. var abc={} will work

Comments

0

I had a variable that was not defined with the var keyword. Solved my issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.