First of all, apologies if the heading question doesn’t exactly match with what I am going to ask.
My problem is that I want to have a loop, and the control is suppose to break out of this loop, once a condition is met.
Now, is it better to use the native JS ‘for loop’ and use ‘return’ or is it better to use the jQuery.each() and use return false, to break out of the loop?
If you can get away with using the plain old JavaScript method of looping over the collection, use it and break out normally.
Unless there is a very good reason to use
jQuery.each(), I try to keep it out of my code as much as possible. It’s really a very simple shortcut and by using plain old JavaScript, I can retain more control over what my code is actually doing.