どうも、ちょげ(@chogetarou)です。
文字列(string)をカンマ区切りで分割する方法を紹介します。
方法

文字列(string)をカンマ区切りで分割するには、split()を使います。
まず、文字列からsplit()を呼び出します。
そして、split()の引数に文字列のカンマを指定します。
const result = text.split(',');
上記のsplit()は、呼び出した文字列をカンマごとに分割した配列を返します。
使用例
const text = "A,BC,DEF,GH,IJK";
const result = text.split(',');
console.log(result);
出力:
[ 'A', 'BC', 'DEF', 'GH', 'IJK' ]
コメント