For simple array members like that, you can use JSON.parse.

var array = JSON.parse("[" + string + "]");

This gives you an Array of numbers.

[0, 1]

If you use .split(), you'll end up with an Array of strings.

["0", "1"]

Just be aware that JSON.parse will limit you to the supported data types. If you need values like undefined or functions, you'd need to use eval(), or a JavaScript parser.


If you want to use .split(), but you also want an Array of Numbers, you could use Array.prototype.map, though you'd need to shim it for IE8 and lower or just write a traditional loop.

var array = string.split(",").map(Number);
Answer from I Hate Lazy on Stack Overflow
๐ŸŒ
Bacancy Technology
bacancytechnology.com โ€บ qanda โ€บ javascript โ€บ how-to-convert-a-string-to-an-array-with-javascript-typescript
How to Convert a String to an Array in JavaScript/TypeScript
August 27, 2024 - /\d+\.\s/ is a regex pattern that matches one or more digits (\d+), followed by a dot (\.), and a space (\s). The split() method separates the string into an array based on this regex pattern.
Discussions

angular - Converting a string into an array in Typescript? - Stack Overflow
The problem is that when I receive the exception response and extract the message, instead of being treated like an Array of strings, it's treated as a single string in the format of: "[message 1, message 2]" Is there a way in typescript to easily convert this String into an array of strings? More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to convert typescript types of strings to array of strings?
I've this type: type myCustomType = "aaa" | "bbb" | "ccc"; I need to convert it to an array like this: ["aaa", "bbb", "ccc"] How can I do this in typescript? More on stackoverflow.com
๐ŸŒ stackoverflow.com
typescript - convert string to a string Array in javascript - Stack Overflow
Sorry , please bare with me , ah I would just like to ask for the terminology and how do we implement or convert a string into something like below. I am not sure if that is string array or somethi... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to convert a string to an array with JavaScript/TypeScript - Stack Overflow
How can I convert a string (which is actually an ordered list) to an array using JavaScript / TypeScript? Unfortunately, this is what the backend returns. The string looks like this: Lorem Ipsum. 2. More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ string-to-array-in-javascript
JavaScript - Convert String to Array - GeeksforGeeks
August 5, 2025 - Modify parts of the string (like replacing characters or extracting substrings). Split a string into smaller components for easier processing. The most common method for converting a string to an array is using the split() method.
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-array-from-string
How to Convert a String to an Array in TypeScript
In this example, the split method splits the string str at each comma, resulting in an array arr containing the individual elements. Another approach is to use the spread operator to convert a string into an array. This method spreads the characters of the string into individual elements of ...
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-from-string-to-array
Converting Strings to Arrays in Typescript: A Complete Guide
One of the most common ways to convert a string to an array in Typescript is by using the split() method.
Find elsewhere
๐ŸŒ
xjavascript
xjavascript.com โ€บ blog โ€บ typescript-string-to-array
TypeScript: Converting Strings to Arrays โ€” xjavascript.com
Converting strings to arrays in TypeScript is a fundamental operation that can be achieved using methods like split() and Array.from(). Understanding the basic concepts and common usage scenarios, along with following best practices, can help you write more efficient and robust TypeScript code.
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-type-string-to-array
Converting TypeScript Type String to Array: A Comprehensive Guide
Before diving into the conversion process, let's discuss why it's important to convert type strings to arrays in TypeScript. When you define an array in TypeScript, you specify its type using square brackets [] followed by the type of elements it can contain.
๐ŸŒ
DEV Community
dev.to โ€บ mehmehmehlol โ€บ from-string-to-array-to-string-f67
From String to Array to String - DEV Community
April 23, 2021 - If you move this to TypeScript, the type of this new copied array does not return as an array of string.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ string-to-array-in-javascript
JavaScript โ€“ Convert String to Array | GeeksforGeeks
April 28, 2025 - Modify parts of the string (like replacing characters or extracting substrings). Split a string into smaller components for easier processing. The most common method for converting a string to an array is using the split() method.
๐ŸŒ
DEV Community
dev.to โ€บ sanchithasr โ€บ 6-ways-to-convert-a-string-to-an-array-in-javascript-1cjg
6 Ways to Convert a String to an Array in JavaScript - DEV Community
September 24, 2022 - Converting from string to array is always done using the split() method but after ES6, there are many tools we could do the same.
๐ŸŒ
SamanthaMing
samanthaming.com โ€บ tidbits โ€บ 83-4-ways-to-convert-string-to-character-array
4 Ways to Convert String to Character Array in JavaScript | SamanthaMing.com
Here are 4 ways to split a word into an array of characters. "Split" is the most common and more robust way. But with the addition of ES6, there are more tools in the JS arsenal to play with ๐Ÿงฐ ยท I always like to see all the possible ways to solve something because then you can choose the best way for your use case. Also, when you see it pop up in someone's codebase, you will understand it with ease ๐Ÿ‘โ€ฌ ยท const string = 'word'; // Option 1 string.split(''); // Option 2 [...string]; // Option 3 Array.from(string); // Option 4 Object.assign([], string); // Result: // ['w', 'o', 'r', 'd']
๐ŸŒ
GoLinuxCloud
golinuxcloud.com โ€บ home โ€บ programming โ€บ javascript โ€บ convert string to array javascript (split, array.from, unicode)
Convert string to array JavaScript (split, Array.from, Unicode)
June 16, 2026 - How to convert string to array ... js string to array, convert string to array javascript with split, Array.from, spread, javascript string to char array, parse string to array javascript regex, emoji-safe iterators, and Intl.Segmenter. TypeScript uses the same runtime ...
๐ŸŒ
Dirask
dirask.com โ€บ posts โ€บ TypeScript-convert-string-to-character-array-1395Bp
TypeScript - convert string to character array
In this article, we would like to show you how to convert string to characters array in TypeScript. Quick solution: Practical examples Using String split() meth...