javascript - Length of Array Differs In Internet Explorer With Trailing Comma -


i'm working data using javascript in form of array. array may contain empty entry @ end, such [1,2,]. in google chrome , firefox, length of example 2; however, in ie, length 3.

in short: internet explorer giving different length array in javascript google chrome , firefox. there way standardize behavior across browsers?

code:

var = [1,]; alert(a.length); 

edit:

a lot of answers saying not have trailing comma, however, data given me in way.

never have trailing commas in ie. period.

that goes arrays too

javascript browser quirks - array.length

to handle edit works (tested in in ie8):

if (a[a.length-1]==null) a.length--; // or a.pop()

for safer test, please @ other suggestion on page: length of array differs in internet explorer trailing comma - demo here

by way, never heard words elision or elided before - learn new here every day


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -