join()

The join() method is used to first convert all of the entries of an array to strings, then concatenate them together into one long string. A charcter or string of text may be specified as the string (see syntax), which will be placed between every string that is to be joined.

syntax:

array.join()

array.join(string)

EXAMPLE

var stringOne = new String("Walk");

var stringTwo = new String("The");

var stringThree = new String("Geek");

var newArray = new Array(stringOne, stringTwo, stringThree);

newArray.join();

document.write(newArray)

The example begins with the creation of stringOne which holds the word "Walk", stringTwo which holds the word "The" and stringThree which holds the word "Geek". The array newArray is then created which has three items which are the three affermentioned strings. The join() method is then performed on the contents of newArray, joining them together. A document.write statement writes the contents of newArray to the screen. The output should look like the following:



Walk,The,Geek