Section 24.8. Array.join( ): concatenate array elements to form a string


24.8. Array.join( ): concatenate array elements to form a string

ECMAScript v1

24.8.1. Synopsis

array.join( )

array.join(separator)

24.8.1.1. 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, a comma is used.

24.8.1.2. 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.

24.8.2. Description

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

You can perform a conversion in the opposite directionsplitting a string into array elementswith the split( ) method of the String object. See String.split( ) for details.

24.8.3. Example

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

24.8.4. See Also

 String.split( ) 




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net