Split A String Into An Array Of Characters

[Solved] Split A String Into An Array Of Characters | Swift - Code Explorer | yomemimo.com
Question : split a string into an array of characters

Answered by : jolly-jellyfish-o11gfj6hunzq

const string = 'hi there';
const usingSplit = string.split('');
const usingSpread = [...string];
const usingArrayFrom = Array.from(string);
const usingObjectAssign = Object.assign([], string);
// Result
// [ 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e' ]

Source : https://www.samanthaming.com/tidbits/83-4-ways-to-convert-string-to-character-array/ | Last Update : Wed, 09 Jun 21

Answers related to split a string into an array of characters

Code Explorer Popular Question For Swift