0
  • i am getting the following error: "Object doesn't support this property or method" in ie8
  • in chrome its fine
  • when i debug ext js code in ie8 its shows undefined for region.getWorld();
  • but where as when I see it in chrome browser I am getting the values
  • providing my code below, can you guys tell me what is the problem
allWidth: function() {
    var me = this,
        states = me.getstates(),
        waterY = 0,
        placeY = 0,
        World;

    states.forEach(function(region) {
        World = region.getWorld();
        if (World.y < placeY) {
            placeY = World.y;
        }
        if (World.y + World.height > waterY) {
            waterY = World.y + World.height;
        }
    });

    return waterY - placeY;
},

1 Answer 1

1

IE8 doesn't support the forEach method for Arrays. You have a few options to fix this.

You could use a normal for loop:

for(var i = 0; i < states.length; i++){
    var region = states[i];
    /* ... */

Since you're using extjs, you could also use the Ext.each method instead:

Ext.each(states, function(region){
...

Or you could use a shim/polyfill to add the forEach method in IE8.

You can find a polyfill for the forEach method on MDN here.

Sign up to request clarification or add additional context in comments.

4 Comments

any idea how to convert this one here.layout.getStates().forEach(function(State) { StateBox.push({ }); });
this is how you could do it using the function in ExtJS. Ext.each(layout.getStates(), function(state){ StateBox.push({}); });
@weeksdev did u miss here by mistake in ur answer here.layout.getStates().
yeah, lol, thought that was the end of your previous sentence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.