[JS] Find a included string
String.includes(substr, pos)
returns true or false when the String includes the word.
console.log("Widget with id".includes("Widget")); // true
console.log("Hello".includes("Bye")); // false
console.log("Widget".includes("id")); // true
console.log("Widget".includes("id", 3)); // false, no "id" after index 3 position
Also, you can use String.startwith()
or String.endwith()
to find a word includes in the text.
console.log("Widget".startsWith("Wid")); // true
console.log("Widget".endsWith("get")); // true
Comments