JavaScript: String.prototype.startsWith

By Xah Lee. Date: . Last updated: .

New in JS2015.

str.startsWith(searchString)
Return true if str starts with searchString. Else, return false.
str.startsWith(searchString, position)
Check if start from position.
const ss = "abcd";

console.log( ss.startsWith("ab") ); // true
console.log( ss.startsWith("b") );  // false

console.log( ss.startsWith("b", 1) ); // true
BUY
ΣJS
JavaScript in Depth

JS Obj Reference

String

prototype