Apologies for deliberately cross-posting, but I have an issue where a JavaScript array in SharePoint is showing a different length from HTML (and an incorrect one!)

SO Question

Updated original to add test javascript

  • Can you make a JS fiddle up of your code please, an example piece of HTML and the JavaScript. jsfiddle.net
    – Hugh Wood
    Nov 14, 2012 at 8:40
  • Could you please give us an example on this code? It's hard to help you when we don't have the code
    – user2536
    Nov 14, 2012 at 8:56
  • not sure the actual code is of any help...SP2010 is returning the SAME javascript array with a different length? The array is identical, the "code" is identical (it's C&P'd) - its just a <script> with an array in there.
    – BlueChippy
    Nov 14, 2012 at 9:45
  • It would be a lot of help BlueChippy. From the information provided it isn't possible to ascertain the reason.
    – Hugh Wood
    Nov 14, 2012 at 10:10
  • The main reason for this, is that you could be using a variable that is already defined, and you are redefining it. From the code we would be able see that, and correct it possibly by scoping your javascript variables properly.
    – Hugh Wood
    Nov 14, 2012 at 10:15

1 Answer 1


I would need to see your javascript code ;) rergardless if its a c&p job! what works for one doesnt mean it would work for another.

Javascript is tempramental in code where sharepoint is not as bad!

As for your code do you have a trailing comma in your code??

this guy explains the issue in more detail :) cba to re-invent the wheel lol

No. IE incorrectly interprets a single trailing comma as an elision and adds one to the length when it shouldn't (ECMA-262 sect. 11.1.4).

Length of Array Differs In Internet Explorer With Trailing Comma.

hope this helps :)

  • Thanks, checked for trailing comma but can't see one in either actual or test code...could SP be adding one somehow?
    – BlueChippy
    Nov 14, 2012 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.