You can split a string into an array of characters in TypeScript using the split() method as shown below:
index.ts165 chars6 lines
In the above code, the split
method is used on the str
variable with an empty string ""
as its argument. This splits the string at every character and returns an array of characters, which is then assigned to the charArray
variable.
Finally, the charArray
variable is logged to the console, which outputs an array of characters as expected.
gistlibby LogSnag