JavaScript array iteration

In this Tutorial we want to describe you a code that make you JavaScript array iteration easy to understand.

JavaScript array iteration

In this Tutorial we want to describe you a code that make you JavaScript array iteration easy to understand.

JavaScript array iteration

JavaScript array iteration

     

In this Tutorial we want to describe you a code that make you JavaScript array iteration easy to understand. For this we are using JavaScript language as scripting language. We use a function new array ( ),inside this function we instantiate an array object that sized for  4 elements. The array variable hold the value of  array element indicated array index[0]-[3]. The function iteration define a variable space and also include for loop that run and execute the script till the variable i is less than the array length. Inside the script, var x  store and assign the value of  new array ( ) function. Finally the document. write print the value of iteration function ,that accept the variable x as a argument.

 

 

 

 

 

JavaScript_Array_iteration.html

<HTML>
<HEAD>
  <h1>JavaScript Array iteration</h1>
  
<TITLE>Array iteration</TITLE>
<SCRIPT> 
 function newarray() { 
 var array = new Array(4)
 array[0"Rose"
 array[1"India"
 array[2".net"
 array[3"Rohini"
 return array; 
 
  function iteration(array){ 
  var space = ""
  for (var i = 0; i < array.length; i++){ 
 space += array[i" "
  
  return space; 
  
 </SCRIPT>
</HEAD>
<BODY>

<SCRIPT> 
  var x = newarray()
  document.write(iteration(x))
 </SCRIPT>

</BODY>
</HTML>

Output of the program

Download source code