Logo

Programming-Idioms

History of Idiom 39 > diff from v33 to v34

Edit summary for version 34 by programming-idioms.org:
New JS implementation by user [programming-idioms.org]

Version 33

2016-12-16, 03:28:41

Version 34

2017-06-29, 14:22:39

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);
Comments bubble
includes was added in ECMAScript 6.
Origin
https://stackoverflow.com/a/1789952/871134