how to turn string into array js code example

Example 1: string to array javascript

const str = 'Hello!';

console.log(Array.from(str)); //  ["H", "e", "l", "l", "o", "!"]

Example 2: js string to array

var myString = 'no,u';
var MyArray = myString.split(',');//splits the text up in chunks

Example 3: javascript turn string into array

var fruits = 'apple, orange, pear, banana, raspberry, peach';
var ar = fruits.split(', '); // split string on comma space
console.log( ar );
// [ "apple", "orange", "pear", "banana", "raspberry", "peach" ]

Example 4: convert a string to array in javascript

let price = "shola";
console.log(Object.values(price));

Tags:

Java Example