Return and Loops

Does the “return” command stop a loop if the statement is false ?
For example

for (let i = 0; i < contacts.length; i++) {
if (name == contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;

in the above scenario it should return “contacts[i].prop;” if the statement is True. But, what if it isn’t does it then go back into the loop ?


Does the “return” command always stop the loop

Whenever a return statement executes, the function immediately exits regardless of any unfinished loops. If the if statement evaluates to false, then the return statement you wrote above would not execute and the code would proceed. Whether or not the loop would continue would be determined by any other code you have written that might trigger a different return statement.

This makes so much sense, thank you !