String.prototype.startsWith() String 的 startsWith() 方法用来判断当前字符串是否以另外一个给定的子字符串开头,并根据判断结果返回 true 或 false 尝试一下 const str1 = 'Saturday night plans'; console.log(str1.startsWith('Sat')); // Expected output: true console.log(str1.startsWith('Sat', 3)); // Expected output: false 官方链接