可以通过检查indexOf()的返回值是否为0来判断字符串是否以指定前缀开头。 javascript let str = "Hello, world!"; let prefix = "Hello"; let result = str.indexOf(prefix) === 0; console.log(result); // 输出: true 使用正则表达式: 可以使用正则表达式中的^符号来匹配字符串的开头。 通过RegExp...