Concatenates the elements of an array, separated by occurrences of the delimiter, from a starting position and to an ending position.
JSV_subjoin(expA [, start, end, delimiter])
expA.subjoin([start, end, delimiter])
Returns the concatenated elements of the array, separated by occurrences of the delimiter.
If start and end are specified, the concatenated elements
beginning at the start element and running to, but not including,
the end element of the array.
The subjoin function uses the following arguments.
| Argument | Description |
| expA | Array being acted upon. |
| start |
Optional. The beginning element of the array.
If start is not provided, the concatenation starts with the first element
of the array (element 0).
|
| end |
Optional. The element of the array included up to but not in the resulting string.
If end is not provided, the concatenation concludes with the last element
of the array (element array length-1).
|
| delimiter |
Optional. Single delimiter used in resulting string.
If delimiter is not provided, a single comma is used.
|
The start, end and delimiter arguments
may be specified in any order.
If start is larger than end, they are swapped
(see the Two results in Example below).
Additionally, to transform an array into a delimited string, the JavaScript
join
function can also be used.
n/a
The following lines of code
var drSeuss = new Array(6);
drSeuss[0] = "One Fish";
drSeuss[1] = "Two Fish";
drSeuss[2] = "Red Fish";
drSeuss[3] = "Blue Fish";
drSeuss[4] = "Green Eggs";
drSeuss[5] = "Green Ham";
document.write( "All: ".bold() + JSV_subjoin(drSeuss) );
document.write( "Five: ".bold() + JSV_subjoin(drSeuss,'$',1) );
document.write( "Four: ".bold() + JSV_subjoin(drSeuss,0,4) );
document.write( "Two: ".bold() + JSV_subjoin(drSeuss,6,"&",4) );
document.write( "One: ".bold() + JSV_subjoin(drSeuss,3,4) );
document.write( "Prototype: ".bold() + drSeuss.subjoin(';',0,4) );
produce
Copyright © 1999-2000 Roaring Fork Software. All rights reserved.