String.prototype.startsWith

Returns true if the string starts with the specified substring.

Syntax

startsWith(searchString, startIndex?)

Parameters

Return value

true if the string starts with the specified substring; otherwise, false.

Examples

"banana".startsWith("ba")
true
"banana".startsWith("na")
false