Question: In my node js App, I have a function that checks if you have the permissions:

```
//queryPermissions is an object that contains all possible permissions:
//each property of queryPermission is an object containing the values to be checked
for (var key in queryPermissions) {
    if (queryPermissions.hasOwnProperty(key)) {
        promisesArray.push(checkThis(key, req.method));
    }
}

Q.all(promisesArray).then(function(response) {
    response.forEach(function(value) {
        //response is an array with all promises' resolved values
        //if all values are true -> access granted
        //if one or more values are false -> access denied
    }
}

```

This works good, but if only one of the values returned by checkThis inside the for loop is false, than the result would be access denied;
so it is not efficient to continue to check other permissions after the first one that resoves with false;
CheckThis returns a promise but sometimes it needs to wait for a query result, sometimes it resolves immediately, it depends.

Is there a way I can break the loop (if it is not finished yet) when the first "checkThis" returns false?

Answer: 
Here is an alternative solution to Bergi's approach - we map false return values to the exceptional condition failures they are and use `Q.all` directly:

Your current code does:

```
for (var key in queryPermissions) {
    if (queryPermissions.hasOwnProperty(key)) {
        promisesArray.push(checkThis(key, req.method));
    }
}

```

We add an additional step:

```
for (var key in queryPermissions) {
    if (queryPermissions.hasOwnProperty(key)) {
        promisesArray.push(checkThis(key, req.method).then(function(val){
             if(!val) throw new Error("Invalid Permissions");
             return true;
        });
    }
}

```

This simple addition would let us use Q directly:

```
Q.all(promisesArray).catch(function(err){
     // one or more authentication errors
}).then(function(){
      // everyone validated, all ok user authenticated here
});

```

This is a more general method - using the exception pipeline for exceptional cases can greatly simplify your code.
It's not possible. Indeed, `Q.all` run parallel promises, so when you want to break, the other promises are still running. So they can't be stopped. One way is to use `Q.spread` but therefore the promises are no more parallel :(.