1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScript - Template literalを使って改行テキストを配列にする

Posted at

ES2015で導入されたTemplate Literalではヒアドキュメントが使えるようになりました。
今まで、マスターデータを使ってコードを書く時に一行一行、クォーテーションマークをつけていましたがそれも不要になる。

const urls = `https://twitter.com/mottox2
https://twitter.com/tbpgr
https://twitter.com/TatumakiGen
https://twitter.com/mitatyandesu`.split('\n')

を実行すると以下のような配列が得られます。
雑に書くときに便利。

[
  'https://twitter.com/mottox2'
  'https://twitter.com/tbpgr'
  'https://twitter.com/TatumakiGen'
  'https://twitter.com/mitatyandesu'
]
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?