JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Array.join() Method

Name

Array.join() Method---concatenate the elements of an array

Availability

Navigator 3.0

Synopsis

array.join()
array.join(separator)

Arguments

separator

An optional character or string used to separate one element of the array from the next in the returned string. If this argument is omitted, the empty string is used.

Returns

The string that results from converting each element of array to a string, and then concatenating them together, with the separator string between elements.

Description

join() converts each of the elements of an array to a string, and then concatenates those strings, inserting the specified separator string between the elements. It returns the resulting string.

Usage

You can perform the opposite direction--split a string up into array elements--with the split() method of the String object.

Example

a = new Array(1, 2, 3, "testing");
s = a.join("+");    s is the string "1+2+3+testing"

See Also

"Array", "String.split()"


Previous Home Next
Array Book Index Array.length

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell