- The entire string against which the original string is checked.
- The index from which you want to start the searching.
Table of Contents
str.startsWith(stringToBeSearched [, startingPosition])
- True: when the specified string is found in the original string.
- False: when the specified string is not found in the original string.
Note: the searching is case-sensitive.
//Case#01: When starting index is not specified var msg = "It is mostly hot in April "; var result = msg.startsWith("It"); console.log(result); result = msg.startsWith("hot"); console.log(result);
//Case#02: When starting index is specified var msg = "It is mostly hot in April"; var result = msg.startsWith("April", 20); console.log(result); result = msg.startsWith("hot", 23); console.log(result);