0
0

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 3 years have passed since last update.

sprit ( )メソッドの使いかた 【JavaScript】

Last updated at Posted at 2020-09-03

##split( )メソッドのポイント:point_up:

  •  splitを直訳すると、 「裂く」 「分ける」。 ボウリングのスプリットをイメージすれば、しっくりくる。

  •  String(文字列) を指定した区切り文字列で分割するメソッド

  •  文字列の空白もカウント。

  •  ''' '半角スペースの有無で、意味が異なる。

##【JavaScript】



  const str = 'あいうえお かきくけこ さしすせそ';
  
  const words = str.split(''); 
  console.log(words[10]); // => ”こ”       空白文字カウント
  
  const chars = str.split(' ');
  console.log(chars[2]); //=> 【さしすせそ】   '' と ' ' で文字列を区切るポイントが異なる

  
  const strCopy = str.split();
  console.log(strCopy); //=>Allay["あいうえお かきくけこ さしすせそ"]

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?