I’m trying to break out of a loop if a certain condition is true. My code works fine until I try and add the break in. The intellisense error in VS2010 and IE8 when running both tell me I cant break outside of a loop, but I don’t think I am.
I’m totally confused so hoping someone can point out something obvious I’m overlooking!
var value1 = "hello";
$.each(myJsonObject.SomeCollection, function () {
if (value1 == this.value2) {
alert("Found it!");
exitFlag = true;
}
if (exitFlag) break;
});
jQuery might not be using a loop for the
.each()function. Maybe returningfalsemight work (in Python it does):