[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String/includes [Back]  [Original]

String.prototype.includes() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

String.prototype.includes()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

includes() String , , , true false.

In this article

const sentence = "The quick brown fox jumps over the lazy dog.";

const word = "fox";

console.log(
  `The word "${word}" ${
    sentence.includes(word) ? "is" : "is not"
  } in the sentence`,
);
// Expected output: "The word "fox" is in the sentence"

js
includes(searchString)
includes(searchString, position)

searchString

. . , , , undefined includes() "undefined", .

position

, searchString. ( 0.)

true, ( searchString ), false .

TypeError

searchString .

, .

includes() . , false:

js
" ".includes(""); // false

:

js
" ".toLowerCase().includes(""); // true

includes()

js
const str = "   ,    .";

console.log(str.includes("")); // true
console.log(str.includes("")); // true
console.log(str.includes("")); // false
console.log(str.includes("", 1)); // false
console.log(str.includes("")); // false
console.log(str.includes("")); // true

Specification
ECMAScript 2027 LanguageSpecification
# sec-string.prototype.includes


Web Proxy Viewer  |  New URL  |  Original Page