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.

Lodash.includesの第一引数に文字列を入れると、部分一致比較になる

Posted at

なぜ書いたか

仕事で書いていたコードがおかしな動きしたので調べていたら、
意図せず部分一致判定になっていてバグったから。

結論

import _ from 'lodash';

_.includes('sora-riku', 'sora'); // Return: true; ☆部分一致判定になる

_.includes(['sora-riku'], 'sora'); // Return: false; ☆完全一致判定になる

なぜこうなる

lodashの仕様です。

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?