I am trying to break from the Object.keys().forEach loop with 'return false', but it doesn't seem to actually break from the loop. Am I doing anything wrong - is it possible to break from a forEach? Or should I use a different looping construct?
function findCollection(name){
var ret = null;
Object.keys(collections).forEach(function (key) {
if (collections.hasOwnProperty(key)) {
var coll = collections[key];
if(coll.uniqueName == name){
ret = coll;
return false;
}
}
});
return ret;
}