ScanSkill

startsWith

The startsWith() method checks the start of the string and matches it with the given value.

Syntax

string.startsWith(searchString)

Example

const name = 'Scan Skill';

console.log(name.startsWith('s')); // Prints: false

console.log(name.startsWith('S')); // Prints: true

The startsWith() checks at the start of the string, if the given string matches with the string it is searching for, if it matches then it returns true, else returns false.