How to split string into char array in Node.js

2 Answers

0 votes
const str = "abcdefghij";
 
let charArray = str.split("");
  
console.log(charArray);


      
/*
run:
      
[
  'a', 'b', 'c', 'd',
  'e', 'f', 'g', 'h',
  'i', 'j'
]
      
*/

 



answered May 2, 2024 by avibootz
0 votes
const str = "abcdefghij";
 
let charArray = [...str];
  
console.log(charArray);


      
/*
run:
      
[
  'a', 'b', 'c', 'd',
  'e', 'f', 'g', 'h',
  'i', 'j'
]
      
*/

 
  
  

 



answered May 2, 2024 by avibootz

Related questions

1 answer 158 views
2 answers 165 views
1 answer 111 views
1 answer 118 views
...