[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/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 9.

includes() , 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

. .

position Optional

searchString . ( 0).

true . false .

TypeError

searchString .

.

includes() . false .

js
"Blue Whale".includes("blue"); // returns false

.

js
"Blue Whale".toLowerCase().includes("blue"); // returns true

includes()

js
const str = "To be, or not to be, that is the question.";

console.log(str.includes("To be")); // true
console.log(str.includes("question")); // true
console.log(str.includes("nonexistent")); // false
console.log(str.includes("To be", 1)); // false
console.log(str.includes("TO BE")); // false
console.log(str.includes("")); // true

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


Web Proxy Viewer  |  New URL  |  Original Page