JavaScript array join

This page discusses - JavaScript array join

JavaScript array join

JavaScript array join

     

In this Tutorial we want to describe you a code that help you in understanding JavaScript array insert. For doing this code we are using JavaScript language as scripting language. We create an array variable that is used to instantiate array object and this array object hold the values of various element in an array object indicated by indexes[0]-[3].The for loop execute the script and return the value of the element of the array before inserting  till the length of i is less than an array length. The document. write print the value of element of the array before inserting that an array object hold.

1)array.push( )   -  This method return you to add  element to an array and provides you the new length of an array and store in a variable current paper.

The document. write print the values of an element in a array after inserting.

javascript_array_insert.html

<html>
  <h1>JavaScript Array insert</h1>
  <title>JavaScript Array insert</title>
  <script language="JavaScript" type="text/javascript">
  var array=new Array();
  array[0]="Rose";
  array[1]="India";
  array[2]=".net";
  array[3]="Rohini"

  document.write("<b>"+"Element of the array before 
  inserting are "
+"</b>""<br />");

  document.write("=================""<br />");
  for(var i=0;i<array.length;i++){
  document.write(array[i]+"<br>")
  }
  document.write"<br />");
  currentPaper = array.push("Delhi","India");
  document.write("<b>"+"Element of the array after 
  inserting are "
+"</b>""<br />");

  document.write("=================""<br />");
  for(var i=0;i<array.length;i++){
  document.write(array[i]+"<br>")
  }
  </script>
</html>

Output of the program

Download source code