startsWith,includes,endsWith 作用 王远祥 2020-10-06 582 阅读1分钟 判断字符串中是否包含指定的内容 const message = 'Error: foo is not defined.' console.log( message.startsWith('Error') // 判断字符串是否已Error开头 message.endsWith('.') // 判断是否已点 . 结尾 // message.includes('foo') // 判断中间是否 包含 foo )