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
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

String

prototype