📅  最后修改于: 2022-03-11 15:02:59.688000             🧑  作者: Mango
//checks if a string starts with a word
function startsWith(str, word) {
return str.lastIndexOf(word, 0) === 0;
}
startsWith("Welcome to earth.","Welcome"); //true