Read array using for- of:- genius student



  • for-of can read all values in a array one by one without using its length.
  • Loop execute until last value of the array.

  • Code:-


  • <!DOCTYPE html> 
  • <html> 
  •  
  • <head> 
  •  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  • </head> 
  •  
  • <body> 
  •  
  •  <input type="button" value="for of array" onclick="read_array();"> 
  •  
  •  <script> 
  •   function read_array() 
  •   { 
  •    var ar = [2, 4, 5, 2, 7, 48, 234]; 
  •  
  •    for (i of ar) 
  •    { 
  •     alert(i); 
  •    } 
  •   } 
  •  </script> 
  • </body> 
  •  
  • </html>
  • Read array using for- of:- genius student Read array using for- of:- genius student Reviewed by Network security on October 18, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.