HTTP/2 200
content-type: text/html
x-guploader-uploadid: AAwnv3I1wCAiySEdY_lDVHNCbVuKg0WuMriBpc5pV7w9KcXgzR0Fjx0uNUnLRcCVkQzBh-kG
cache-control: public, max-age=3600
expires: Wed, 08 Oct 2025 21:01:18 GMT
last-modified: Wed, 08 Oct 2025 01:14:01 GMT
etag: W/"e2275461210d9aceb9ee6eea4ee07dc2"
x-goog-generation: 1759886041354275
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 173784
x-goog-meta-goog-reserved-file-mtime: 1759884301
x-goog-hash: crc32c=9m2Wxg==, md5=4idUYSENms657m7qTuB9wg==
x-goog-storage-class: STANDARD
accept-ranges: none
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
alt-svc: clear
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
strict-transport-security: max-age=63072000
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net mdn.github.io live-samples.mdn.mozilla.net live-samples.mdn.allizom.net *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-frame-options: DENY
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-cloud-trace-context: 98b7aafbbd27180093876766aa40a48e
date: Wed, 08 Oct 2025 20:01:19 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache: miss
String.prototype.includes() - JavaScript | MDN
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`,
);
// 予想される結果: "The word "fox" is in the sentence"
includes(searchString)
includes(searchString, position)
searchString
str
の中で検索される文字の集合です。正規表現 にすることはできません。正規表現ではない値はすべて文字列に変換されます ので、省略したり undefined
を渡したりすると、includes()
は "undefined"
という文字列を検索します。これはおそらく望むところではないでしょう。
position
省略可
文字列内で searchString
を検索し始める位置です。(既定値は 0
です。)
検索文字列が指定された文字列の中で見つかった場合、searchString
が空文字列の場合は true
。そうでなければ false
です。
TypeError
searchString
が正規表現であった場合 に発生します。
このメソッドで、ある文字列が別な文字列の中に含まれているかどうかを判断することができます。
includes()
メソッドは大文字と小文字が区別します。例えば、次のコードでは false
を返します。
"Blue Whale".includes("blue"); // false を返す
元の文字列と検索文字列の両方をすべて小文字に変換することで、この制約を回避することができます。
"Blue Whale".toLowerCase().includes("blue"); // true を返す
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