The API is down for maintenance. You can continue to browse the MDN Web Docs, but MDN Plus and Search might not be available. Thank you for your patience! 面向开发者的 Web 技术 JavaScript JavaScript 参考 JavaScript 标
startsWith()方法用来判断当前字符串是否是以另外一个给定的子字符串“开头”的,根据判断结果返回true或false。 语法 str.startsWith(searchString[,position]); 参数 searchString 要搜索的子字符串。 position 在str中搜索searchString的开始位置,默认值为 0,也就是真正的字符串开头处。
JavaScript built-in: String: startsWith Global usage 95.3% + 0% = 95.3% IE ❌ 6 - 10: Not supported ❌ 11: Not supported Edge ✅ 12 - 135: Supported ✅ 136: Supported Firefox ❌ 2 - 16: Not supported ✅ 17 - 137: Supported ✅ 138: Supported ✅ 139 - 141: ...
If you ever need help reading a regular expression, check out thisregular expression cheat sheetby MDN. It contains a table with the name and the meaning of each special character with examples. I wrotea bookin which I share everything I know about how to become a better, more efficient ...
If you ever need to check if a string begins with another string in JavaScript, use ES6's startsWith method...
The position in this string at which to begin searching forsearchString; defaults to 0. Return value trueif the string begins with the characters of the search string; otherwise,false. Description This method lets you determine whether or not a string begins with another string. This method is...