String.prototype.includes

ES6

Includes is self explanatory, you can check if a string contains another string.

Previously you could check that the indexOf the string is more than 0, but it's not that clear.

'Hello Dave'.indexOf('Dave') > 0; // true


Now the intent is much clearer...

'Hello Dave'.includes('Dave'); // true

results matching ""

    No results matching ""