javascript - Does Internet Explorer 9 choke on extra commas at the end of array and object literals? -
modern browsers , environments node.js allow {a:1, b:2,} or [1,2,3,]. has historically been problematic internet explorer. fixed in internet explorer 9?
there 2 different answers this, 1 dangling commas in object initializers , 1 dangling commas in array initializers:
for object initializers, e.g.:
var obj = { a: 1, b: 2, c: 3, };
it's fixed in ie8 , above. test here: http://jsbin.com/uxuhopec/1 (source). ie7 , earlier throw syntax error on }
after dangling comma.
for array initializers, e.g.:
var arr = [ 1, 2, 3, ];
it "fixed" in ie9 , above. test here: http://jsbin.com/uxuhopec/2 (source). ie8 , earlier give array four entries, last 1 having value undefined
. ie9 , above give 3 entries.
i put "fixed" in quotes because spec unclear whether array should have final undefined
entry or not, neither behavior incorrect. it's ie went 1 way , else went other. :-)
Comments
Post a Comment