Dojo.forEach Error: No match found

Errors in Javascript can be irritating sometimes, so I thought I’d start posting when I ran across one that didn’t show up when I googled for it. Here’s my first one, it’s a simple error thrown by dojo.forEach.

I got this very descriptive error message in my console: “Error: No match found”.

Firebug Error for Dojo.forEach

Firebug Error for Dojo.forEach


I stared at it and then my code for a while before realizing that I had a reference to “this” inside my forEach loop, without giving the scope. I’d written:

1
2
3
dojo.forEach(array, function(entry){
     this.something;
});

When what I should have written was:

1
2
3
dojo.forEach(array, function(entry){
     this.something;
}, this);

The third parameter here, “this”, gave the scope forEach needed to be able to access the scope in the loop.

Leave a Reply

Spam protection by WP Captcha-Free