join

.join( separator = ', ' )

Turns the whole array into a string, and returns it. This is achieved by converting each element into a string, and joining them using the 'separator'.

By default elements are separated by a comma, but you can pass in your own separator to join them with a different string.

names = [ "Brian", 'Graham', 'Ashley' ]

// set to "Brian, Graham, Ashley"
namesStr = names.join()

// set to "10x100"
location = [ 10, 100 ].join( 'x' )

ns = [ 1, 2, 3, 4, 5 ]

// set to '12345'
nsStr = ns.join( '' )

See also

toString