Beware trailing comma in JavaScript prototypes
Submitted by winter on Tue, 09/02/2008 - 15:03.
I spent more time than I care to admit tracking down this one, perhaps this post will save someone else the trouble...
When defining a number of functions in a prototype in JavaScript, do not include a trailing comma after the last function:
MyType.prototype = {
foo : function() {
// ...
},
bar : function() {
//...
}, //<- fails in IE!
}
What was especially tricky about tracking this problem down was that FireFox works with or without the trailing comma, so it only fails in IE!

Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket
Post new comment