Home Java Javascript-array JavaScript array iteration

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript array iteration

Advertisement
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. 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

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 10, 2008

Related Tutorials

Discuss: JavaScript array iteration  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com