Enemies[0] do not work

WHY this work?:

while(true) {
     var enemies = hero.findEnemies();
for (var i = 0; i < enemies.length; ++i) {
    var enemy = enemies[i];
    hero.attack(enemy);
    }
}

BUT this not work?!:

while(true) {
    
    var enemies = hero.findEnemies();
    if (enemies) {
        var i = 0;
        var enemy = enemies[i];
           hero.attack(enemy);
    }

}

Because if there are no enemies then enemies is []. In JS an empty array is true.