example of while loop in javascript with array length

JavaScript
var soccerTeams = ['Barca','Madrid','Gunners','City','PSG']
var x=0;

while( x <= soccerTeams.length) {
  console.log(soccerTeams[x])
  x++;
}

======== output ===========
Barca
Madrid
Gunners
City
PSG
undefined
5
Source

Also in JavaScript: