How to split string into char array in TypeScript

2 Answers

0 votes
const str: string = "abcd";
 
let charArray: string[] = str.split("");
  
console.log(charArray);
    
      
      
      
/*
run:
      
["a", "b", "c", "d"] 
      
*/

 



answered Oct 29, 2021 by avibootz
edited May 2, 2024 by avibootz
0 votes
const str: string = "abcd";
 
let charArray: string[] = [...str];
  
console.log(charArray);
    
      
      
      
/*
run:
      
["a", "b", "c", "d"] 
      
*/

 



answered May 2, 2024 by avibootz
...