change array to string javascript code example

Example 1: js array to string

var myArray = ['no','u'];
var myString = myArray.toString();

Example 2: javascript convert in a string the items of an array

const arr = [1, 2, 'a', '1a'];
const str = arr.toString();
console.log(str); //> "1,2,a,1a"

Example 3: how to print a array js

var array = [1,2,3]

for(var i = 0; i < array.length ; i++){
    console.log(array[i])
}

Example 4: array to string javascript

<array>.join(<splitting character(s)>);

Example 5: how to convert array converted to string back to array javasccript

var array = '[[1, 2, 3], [4, 5, 6]]';
JSON.parse(array);