contents   index   previous   next



Array join()

syntax:

array.join([separator])

where:

separator - a value to be converted to a string and used to separate the list of array elements. The default is an empty string.

 

return:

string - string consisting of the elements, delimited by separator, of an array.

 

description:

The elements of the current object, from 0 to the length of the object, are sequentially converted to strings and appended to the return string. In between each element, the separator is added. If separator is not supplied, then the single-character string "," is used. The string conversion is the standard conversion, except the undefined and null elements are converted to the empty string "".

 

The Array join() method creates a string of all of array elements. The join() method has an optional parameter, a string which represents the character or characters that will separate the array elements. By default, the array elements will be separated by a comma. For example:

 

var a = new Array(3, 5, 6, 3);

var string = a.join();

 

will set the value of "string" to "3,5,6,3". You can use another string to separate the array elements by passing it as an optional parameter to the join() method. For example,

 

var a = new Array(3, 5, 6, 3);

var string = a.join("*/*");

 

creates the string "3*/*5*/*6*/*3".

 

see:

Array toString()

 

example:

// The following code:

 

var array = new Array( "one", 2, 3, undefined );

Screen.writeln( array.join("::") );

 

// Will print out the string "one::2::3::".

 


Array pop()