“String to Array JavaScript” Code-Antworten

Konvertieren Sie die Zeichenfolge in Array JS

// our string
let string = 'ABCDEFG';

// splits every letter in string into an item in our array
let newArray = string.split('');

console.log(newArray); // OUTPUTS: [ "A", "B", "C", "D", "E", "F", "G" ]
snakebite_382

JavaScript explodieren

//split into array of strings.
var str = "Well, how, are , we , doing, today";
var res = str.split(",");
Grepper

JS String to Array

// string
let string = '12345';

// splits characters string into items in our array
let array = string.split('');

console.log(array); // [ "1", "2", "3", "4", "5"]
Caffeinated Developer

String to Array JavaScript

const str = 'Hello!';

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

String to Array JavaScript

// If you want to split on a specific character in a string:
const stringToSplit = '01-02-2020';
console.log(stringToSplit.split('-')); 
// ["01", "02", "2020"]

// If you want to split every character:
const stringToSplit = '01-02-2020';
console.log(Array.from(stringToSplit));
// ["0", "1", "-", "0", "2", "-", "2", "0", "2", "0"]
RWL_Dittrich

String to Array JavaScript

const string = "Hello!";

console.log([...string]); // ["H", "e", "l", "l", "o", "!"]
kripi__

Ähnliche Antworten wie “String to Array JavaScript”

Fragen ähnlich wie “String to Array JavaScript”

Weitere verwandte Antworten zu “String to Array JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen