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 1 year has passed since last update.

JavaScript 文字列の中に特定の文字列が存在するかを判定する includes()

Last updated at Posted at 2023-04-05

概要

  • 文字列の中に特定の文字列が存在するかを判定する方法を簡単にまとめる。

方法

  1. includes()を使って下記のように判定する。

    let str = "hoge fuga piyo";
    
    console.log(str.includes('hoge'));
    
  2. 上記を実行してincludes()の引数で指定した文字列が変数strの中に格納された文字列に存在していた場合trueを返す。存在していなかった場合falseを返す。

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?