Methods of Arrays
  1. concat() Method

    The concat() method takes two or more arrays, concatinates them together, and puts the result into a new array. Pay attention to the order in which you concatinate your arrays. Which ever you name first, second etc will be concatinated in that order. For example:

    	var hockey=new Array("stick","puck");
    	var basketball=new Array("basketball","hoop");
    	var tennis=new Array("racket","tennis ball");
    	var sports=hockey.concat(basketball,tennis);
    	
    hockey is first, basketball second and tennis at the end. click here to see the demo.
    Multi-dimensional demo - click here to see the demo.

  2. join() Method

    The join() method takes all the elements in an array and puts them into one string seperating each by a comma (default) or by a seperator that is supplied. For instance all the elements in the hockey array could be joined together and put into a variable with each element seperated by a comma or semi-colon.

    	var hockey=new Array("stick","puck");
    	var hockey_esentials = hockey.join(";");
    	document.write(hockey_esentials);
    	
    click here to see the demo.

  3. reverse() Method

    This method reverses the order of the elements in an array making the first last and the last first.

    	var hockey=new Array("stick","puck","goaly");
    	hockey.reverse();
    	
    click here to see the demo.
    multi-dimensional demo - click here to see the demo.

  4. sort() Method

    This method sort the elements in an array.

    	var hockey=new Array("stick","puck","goaly");
    	hockey.sort();
    	
    click here to see the demo.
    multi-dimensional demo - click here to see the demo.

  5. pop() Method

    This method is currently only supported by Netscape 6.0 and above. The pop method is used to remove and return the last element of an array. This affects the length of the array. Using the pop method on the hocky array above removes and returns the last element "puck" leaving just one element "stick" in the array:

    	var hockey=new Array("stick","puck");
    	var removeFromHockeyList = hockey.pop();
    	document.write("you just removed the " + removeFromHockeyList + " from the hockey array.");
    	
    click here to see the demo.

  6. push() Method

    This method is currently only supported by Netscape 6.0 and above. The push method is used to add one or more elements at the end of an array. This affects the length of the array. Using the push method on the hocky array above adds "goaly" at the end of the array.

    	var hockey=new Array("stick","puck");
    	hockey.push("goaly");
    	document.write("you just added the " + hockey[2] + " to the hockey array.");
    	
    click here to see the demo.