Example 1: js array to string
var myArray = ['no','u'];
var myString = myArray.toString();
Example 2: string to array javascript
const stringToSplit = '01-02-2020';
console.log(stringToSplit.split('-'));
const stringToSplit = '01-02-2020';
console.log(Array.from(stringToSplit));
Example 3: java string array to one string
public class ArrayOfStrings {
public static void main(String args[]) {
String stringArray[] = {"Hello ", " how", " are", " you", " welcome", " to", " Tutorialspoint"};
StringBuffer sb = new StringBuffer();
for(int i = 0; i < stringArray.length; i++) {
sb.append(stringArray[i]);
}
String str = sb.toString();
System.out.println(str);
}
}
Example 4: java srting array to string
Arrays.toString(charArr);
Example 5: turn array into string
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));
Example 6: array to string
var array = [1, 2, 3, 'I', 'II', 'III', 'ūnus', 'duo', 'trēs']
console.log(
'%s\n%s\n%s',
array.toString(),
String(array),
array + ''
)
console.assert(
typeof array.toString === typeof array.join &&
array.toString() === array.join(),
'%o.%O utilizes fallback method %s.%O instead of the default .%O',
array,
array.toString,
'Object.prototype',
Object.prototype.toString,
array.join || Array.prototype.join
)
console.log(
'%s\n%s',
array.toString(),
(array.join = null) || array.toString()
)
Array.prototype.toString ||
Object.defineProperty(Array.prototype, 'toString', {
value : function toString () {
return typeof this.join === 'function'
? this.join()
: typeof Object.prototype.toString === 'function'
? Object.prototype.toString.call(this)
: '[object Array]'
},
configurable: true,
writable: true
})