GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • JS Tutorial
  • Web Tutorial
  • A to Z Guide
  • Projects
  • OOP
  • DOM
  • Set
  • Map
  • Math
  • Number
  • Boolean
  • Exercise
  • Introduction3 min read
  • Variables5 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — JavaScript String includes() Method - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • JS Tutorial
  • Web Tutorial
  • A to Z Guide
  • Projects
  • OOP
  • DOM
  • Set
  • Map
  • Math
  • Number
  • Boolean
  • Exercise

JavaScript String includes() Method

Last Updated : 1 Jun, 2026

The includes() method is used to check whether a string contains a specific value. It returns a boolean result based on whether the text is found or not.

  • Returns true if the string contains the specified value.
  • Returns false if the value is not found.
  • It is case-sensitive, so uppercase and lowercase letters are treated differently.
JavaScript
let text = "JavaScript is awesome";

let result = text.includes("awesome");

console.log(result);

Syntax:

string.includes(searchvalue, start)

Parameters:

The includes() method accepts parameters that control how the search is performed. These parameters define what to search for and where to start searching.

  • searchValue: The string that needs to be searched.
  • start: The position from where the search begins.
  • If start is not provided, the search starts from the beginning of the string.

Return Value:

The includes() method provides a simple true or false result. This result tells whether the given value exists in the string.

  • Returns true if the value is present.
  • Returns false if the value is not found.

Example 1: The code checks whether "Geeks" exists in "Welcome to GeeksforGeeks." and logs true because the substring is found.

javascript
let str = "Welcome to GeeksforGeeks.";
let check = str.includes("Geeks");
console.log(check);


Example 2: Here, the second parameter is not provided, so the search starts from index 0. Since the method is case-sensitive, it treats the strings differently and therefore returns false.

javascript
let str = "Welcome to GeeksforGeeks.";
let check = str.includes("geeks");
console.log(check);


Example 3: The code checks whether the character "o" exists in "Welcome to GeeksforGeeks." starting from index 17 and logs false, since "o" does not appear after that index.

javascript
let str = "Welcome to GeeksforGeeks.";
let check = str.includes("o", 17);
console.log(check);


Example 4: If the computed index (starting index) i.e. the position from which the search will begin is less than 0, the entire array will be searched. 

javascript
let str = "Welcome to GeeksforGeeks.";
let check = str.includes("o", -2);
console.log(check);
Comment

Explore

    JavaScript Basics
    • Introduction3 min read
    • Variables5 min read
    • Operators4 min read
    • Control Statements4 min read
    Array & String
    • Arrays6 min read
    • Array Methods4 min read
    • String5 min read
    • String Methods8 min read
    Function & Object
    • Functions4 min read
    • Function Expression3 min read
    • Function Overloading4 min read
    • Objects4 min read
    • Constructors4 min read
    OOP
    • OOP5 min read
    • Classes & Objects4 min read
    • Access Modifiers5 min read
    • Constructor4 min read
    Asynchronous JavaScript
    • Asynchronous2 min read
    • Callbacks4 min read
    • Promises4 min read
    • Event Loop3 min read
    • Async Await Fuction3 min read
    Exception Handling
    • Error and Exceptional Handling5 min read
    • Errors Throw & Try to Catch2 min read
    • Custom Errors2 min read
    • TypeError Invalid Array.prototype.sort argument1 min read
    DOM
    • DOM8 min read
    • DOM Elements3 min read
    • Custom Events4 min read
    • Addeventlistener5 min read
    Advanced Topics
    • Closure3 min read
    • Hoisting5 min read
    • Scope4 min read
    • Higher Order Functions7 min read
    • Debugging3 min read
    Courses
    • Placement 360 Course2 min read
    • MERN Full Stack Course2 min read
    • DSA and System Design Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.