Logo

Programming-Idioms

History of Idiom 39 > diff from v44 to v45

Edit summary for version 45 by programming-idioms.org:
[JS] +DocURL

Version 44

2019-10-14, 12:24:24

Version 45

2019-10-17, 10:52:47

Idiom #39 Check if string contains a word

Set boolean ok to true if string word is contained in string s as a substring, or to false otherwise.

Idiom #39 Check if string contains a word

Set boolean ok to true if string word is contained in string s as a substring, or to false otherwise.

Code
var ok = s.includes(word);
Code
var ok = s.includes(word);
Comments bubble
includes was added in ECMAScript 6.
Comments bubble
includes was added in ECMAScript 6.
Doc URL
https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/String/includes
Origin
https://stackoverflow.com/a/1789952/871134
Origin
https://stackoverflow.com/a/1789952/871134