String.startsWith

startsWith — Check if the string ends with this string.

Description

String.startsWith(string string)

Parameters

Name Description Type Default Optional
string string No

Return values

boolean primitive.

Changelog

Version Description
ES 6 Introduced.

Examples

Example #1 – startsWith example
console.log('Hello World'.startsWith('World')); // false console.log('Hello World'.startsWith('Hello')); // true

External references