In ES6, the includes()
method is used to determine whether one string may be found within another string, returning true
or false
as appropriate.
var 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
Here is jsperf…
Top comments (0)