最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - My IE9 is fine with trailing comma, user's IE9 is not; why? - Stack Overflow

programmeradmin5浏览0评论

I have a web app with a JavaScript file using code like the following:

var foo = {a:'b',c:'d',e:'f',};

On my puter, IE9 (9.0.8112.16421) works correctly; the JavaScript is parsed and executed as on Chrome/FF/Safari. Another user claims to have the same version of IE, yet gets this error in the Developer Tools Console:

SCRIPT1028: Expected identifier, string or number 
blob.js?modified=1304026278, line 524 character 136

Column 136 is the trailing ma/closing brace for the object literal.

I've 'fixed' the code so the user should have no more problems, but I'm wondering:
What could make the same version of IE on two different puters treat the JavaScript differently?

I have a web app with a JavaScript file using code like the following:

var foo = {a:'b',c:'d',e:'f',};

On my puter, IE9 (9.0.8112.16421) works correctly; the JavaScript is parsed and executed as on Chrome/FF/Safari. Another user claims to have the same version of IE, yet gets this error in the Developer Tools Console:

SCRIPT1028: Expected identifier, string or number 
blob.js?modified=1304026278, line 524 character 136

Column 136 is the trailing ma/closing brace for the object literal.

I've 'fixed' the code so the user should have no more problems, but I'm wondering:
What could make the same version of IE on two different puters treat the JavaScript differently?

Share Improve this question asked Jun 28, 2011 at 17:32 PhrogzPhrogz 303k113 gold badges667 silver badges756 bronze badges 1
  • as a sidenote, when you place a trailing mar in an array e.g. a,b,c, this array contains 4 not 3 items, the 4th being 'undefined'. Another reason to avoid trailing mars. ( some browsers would say there are 3 and assume the trailing ma is human error ) – Tom J Nowell Commented Oct 3, 2011 at 16:15
Add a ment  | 

2 Answers 2

Reset to default 22

One of the reasons may be that user has pressed the "Compatibility View" button. The trailing ma causes syntax error in IE7 document mode.

Its most likely due to a browser setting suppressing the error on your browser.

发布评论

评论列表(0)

  1. 暂无评论