Question : how to split string into array javascript
Answered by : flashingmustard
var str = 'foobar';
var arr = str.split('');
console.log(arr); // ["f", "o", "o", "b", "a", "r"]
Source : | Last Update : Mon, 15 Nov 21
Question : javascript split by character
Answered by : kostas-minaidis
// Split by "-"
"hello-from-javascript".split("-");
// Result: ["hello", "from", "javascript"]
// Split by "-" or "_"
"hello-from_javascript".split(/-|_/g);
// Result: ["hello", "from", "javascript"]
// Use a RegEx group (...) if you want to keep the separator in the array:
"hello-from_javascript".split(/(-|_)/g);
// Result: ["hello", "-", "from", "_", "javascript"]
Source : https://tinytip.co/tips/js-split-keep-separator/ | Last Update : Thu, 20 Jul 23
Question : split array by character javascript
Answered by : ravi-jajam
s.split("");
Source : https://stackoverflow.com/questions/6484670/how-do-i-split-a-string-into-an-array-of-characters | Last Update : Tue, 22 Dec 20