Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove array delimiters

Tags:

javascript

Is it possible remove delimiters when you array.toString? (javascript)

var myArray = [ 'zero', 'one', 'two', 'three', 'four', 'five' ];
var result = myArray .toString();

result shoud be "zeroonetwothreefourfive"

like image 827
Demion Avatar asked Dec 06 '11 13:12

Demion


1 Answers

You could use join instead of toString -

var myArray = [ 'zero', 'one', 'two', 'three', 'four', 'five' ];
var result = myArray.join('');

join will join all the elements of the array into a string using the argument passed to the join function as a delimiter. So calling join and passing in an empty string should do exactly what you require.

Demo - http://jsfiddle.net/jAEVY/

like image 73
ipr101 Avatar answered Oct 03 '22 06:10

ipr101