JavaScript for loop

1/22/2020 12:34:15 AM

JavaScript has for loop. When we want work with collection or array then some time use the for loop. But looping mechanism means when we work repeat by the condition then we use loop in JavaScript.  JavaScript loop is very important. Basically, for loop have three part one is Initializing another is conditional and last part is increment or decrement. Now given bellow the example code and explain the code:

<!DOCTYPE html>
<script type="text/javascript">
  // JavaScript for loop
    var myName="Farhan Sakib Jesy";
for (var i = 1; i <= 5; i++) {
var name = ["Jesy", "Reza", "Tofile"];
for (var i = 0; name.length; i++) {

In this part we print the name and then we print the array using for-loop. This loop will use also another purpose also your need.