[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith [Back]  [Original]

String.prototype.startsWith() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

String.prototype.startsWith()

Baseline

20159

startsWith() String true false

const str = "Saturday night plans";

console.log(str.startsWith("Sat"));
// : true

console.log(str.startsWith("Sat", 3));
// : false

js
startsWith(searchString)
startsWith(searchString, position)

searchString

str undefined startsWith() "undefined"

position

searchString searchString 0

searchString true false

TypeError

searchString

startsWith()

js
const str = "To be, or not to be, that is the question.";

console.log(str.startsWith("To be")); // true
console.log(str.startsWith("not to be")); // false
console.log(str.startsWith("not to be", 10)); // true

ECMAScript 2027 LanguageSpecification
# sec-string.prototype.startswith


Web Proxy Viewer  |  New URL  |  Original Page