UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

13 lines (12 loc) 470 B
/** * Checks if a string contains a substring. * @param {string} string - The string to search in. * @param {string} substring - The substring to search for. * @returns {boolean} True if the substring is found, false otherwise. * @example * const result = contains('Hello, world!', 'world'); // true * const result2 = contains('Hello, world!', 'universe'); // false */ export function contains(string, substring) { return string.indexOf(substring) !== -1; }