The
includes()
method determines whether an array includes a certain value among its entries, returningtrue
orfalse
as appropriate.(c)MDN
🐊Putout plugin adds ability to convert indexOf
to includes
.
npm i @putout/plugin-convert-index-of-to-includes -D
{
"rules": {
"convert-index-of-to-includes": "on"
}
}
if (~array.indexOf(element)) {}
if (array.includes(element)) {}
MIT