I understand return basically terminates a function. But somehow in this case, I'm not sure which return is actually finishing up a function.
var THRESHOLD = 12;
var v = [5, 2, 16, 4, 3, 18, 20];
var res;
res = v.some(function(element, index, array) {
console.log('element:', element);
if (element >= THRESHOLD) {
return true; //#1
}
return false; // #2
});
console.log('res:', res);
Say it's iterating at v[0]=5, it skips if(){} and go ahead to return false //2,
Why is that after #2 return, the function still keep looping?