Modern JavaScript Web Development Cookbook
上QQ阅读APP看书,第一时间看更新

Searching in strings

There are new functions to determine whether a strings starts with, ends with, or includes a given string. This can give you much relief from using indexOf(...) and length-related calculations:

"Hello, there!".startsWith("He"); // true
"Hello, there!".endsWith("!"); // true
"Hello, there!".includes("her"); // true