LoginSignup
211
185

More than 5 years have passed since last update.

【javascript】配列と文字列の変換

Posted at

配列→文字列

区切り文字列で結合する。

ary = ['Spring','Summer','Fall','Winter'];
str = ary.join(',');
console.log(str);
//=>Spring,Summer,Fall,Winter

文字列→配列

区切り文字列で配列にする。

str = 'Spring,Summer,Fall,Winter';
ary = str.split(',');
console.log(ary);
//=>["Spring", "Summer", "Fall", "Winter"] 
211
185
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
211
185