views:

364

answers:

2

I get this error in IE8,

Object doesn't support this property or method

on this line.

this.results.forEach(function(a){if(!a.views){a.views=0}})

I am new to sifr and fairly new to Javascript so i am not sure on what to do here. If someone could point me in a "helpfull" direction that would be wonderful.

thanks Jason

Link to site: http://godgrrl.mytrainsite.com/home

A: 

You don't get a forEach method on arrays in any version of IE so far. Array.prototype.forEach is an ECMA-262 Fifth Edition feature which you can't rely on being available: the browser support baseline is Third Edition, where there is no map, filter, forEach or even indexOf on arrays.

You can correct this by hacking the Array.prototype to add the method if you like. See MDC's code, for example. Or, if you are using the prototype library, as you seem to be, you can use .each, which hides the difference from you.

ECMA-262 is really hard to read; A useful place to look for the real supported-everywhere baseline for built-in types is in the old Netscape 4-era JavaScript reference. Ignore the DOM stuff which is best documented elsewhere, but it's good for the JavaScript built-in types.

bobince
Thanks that helped me narrow it down. Was actually in the Twitter widget and not in the sifr replacement tool. Thanks again
Jason Van Vuren
You should accept this answer by clicking the hollow check.
SLaks
A: 

Thx bobince! You saved me a lot of time :)

Stacksyard