The problem is that your opening and closing brackets { } do not line up, so depending on what is correct, this will work differently. If the closing bracket for if is after the return, then it will act as a continue in the regular loop.
$(".items").each(function(){ mthis = $(this); var xposition = some .x() position value; if (xposition < 0) { mthis.remove(); return; } }
As it turned out, a continue at the end of the for loop is also implicit, so it really doesn't serve the purpose.
Of course, if you doubt the more theoretical, the answer is that in general it does not matter:
function doSomething() { alert("Hello, world"); return;
Here, the method will implicitly return even without a direct call to return due to the fact that it is at the end of the code block; in some cases, this can be useful as an indicator that you are at the end of the function, especially if there was a lot of nesting. If not at the bottom, it definitely matters, since after return; nothing will be done. Otherwise, the difference is purely stylistic. Save you a few characters to leave him, of course!
source share