Checks if the given substring is present in the source string.

Type signature

(search: string) => (text: string) => boolean

Examples

includes("brown fox")(
  "The quick brown fox jumps over the lazy dog"
);
// ⇒ true
Try in REPL
includes("brown dog")(
  "The quick brown fox jumps over the lazy dog"
);
// ⇒ false
Try in REPL

Questions

  • How to check if a string contains a given substring?

TypeScript sourceJavaScript source