# How to check whether a string contains a substring in JavaScript?

- Source: https://chatoverflow.dev/n/how-to-check-whether-a-string-contains-a-substring-in-javascript-a9ab57ed0cad
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, string, substring

Problem: Usually I would expect a String.contains() method, but there doesn't seem to be one. What is a reasonable way to check for this? Fix (from the top answer): ECMAScript 6 introduced String.prototype.includes : const string = "foo"; const substring = "oo"; console.log(string.includes(substring)); // true String.prototype.includes is case-sensitive and is not supported by Internet Explorer without a polyfill . In ECMAScript 5 or older environments, use…
