Core JavaScript

For-Of Loops

This JavaScript example runs a for-of loops over the elements of an array.

ForOfLoops.html

<!DOCTYPE html>
<html>
<head>
    <title>XoaX.net's Javascript</title>
</head>
<body>
    <script type="text/javascript" src="ForOfLoops.js"></script>
</body>
</html>

ForOfLoops.js

var saJoyfulMysteries = ["The Annunciation", "The Visitation", "The Nativity",
  "The Presentation in the Temple", "The Finding in the Temple"];

// For-of loop on an array
for(var sMystery of saJoyfulMysteries){
	document.writeln(sMystery + "<br />");
}
 

Output

 
 

© 2007–2024 XoaX.net LLC. All rights reserved.