Finds string within another string.
Donate to NGO Julenka. Support Ukranians in need.
Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.
string.includes() determines if a string can be found inside another one
finding a single character
- can be done (a character is also a string, in JS)
- reports false if character was not found
find a string
search for an empty string, is always true
- in an empty string
- search for
undefined in a string fails
- searches are case-sensitive
- must NOT be a regular expression
coerces the searched "thing" into a string
- e.g. from a number
- e.g. from an array
- e.g. from an object, with a
takes a position from where to start searching
- does not find
a after position 1 in
- even the position gets coerced
invalid positions get converted to 0
- negative numbers
The official specification, actually quite good to read for this function.
The Mozilla Developer Network docs, contains good examples.