Code:
function hasEnemyLeftBounds(enemies) {
return enemies.every( function(enemy) {
return enemy.x <= 0 || enemy.x >= Game.CANVAS_WIDTH ;
} );
}
where enemies is an array and you want to know if all enemies satisfy the condition.
every() terminates upon the first falsy return value, so you don't need a collector or status var like you would if you tried to use .forEach(), and you can bail-out early, which is much faster in practice.
if you want all enemies that satisfy the condition, replace the word "every" with "filter".
if you want to end iteration when the first condition is trueish (as opposed to falsy), use .some() instead of .every().