Hello,
In MDN doc : " The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate."
includes()
true
false
But If I use a string:
let string = 'string' console.log(string.includes('i'))
That’s works well. Why ?
includes is also defined on the string prototype:
includes
There are a fair number of methods that work on both strings and arrays. When I’m in doubt, I just Google “MDN methodname” and if its defined for both arrays and strings those two pieces of documentation are typically the first two results.
Yes, good trick ! Thanks again as usually.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.