在操作字符串(String)类型的时候,startsWith(anotherString)和endsWith(anotherString)是非常好用的方法。其中startsWith判断当前字符串是否以anotherString作为开头,而endsWith则是判断是否作为结尾。举例:"abcd".startsWith("ab"); // true "abcd".startsWith("bc"); // false "abcd".endsWith("cd"); // true "abcd".endsWith("e"); // false "a".startsWith("a"); // true "a".endsWith("a"); // true但不幸的是,...
在操作字符串(String)类型的时候,startsWith(anotherString)和endsWith(anotherString)是非常好用的方法。其中startsWith判断当前字符串是否以anotherString作为开头,而endsWith则是判断是否作为结尾。举例: "abcd".startsWith("ab"); // true "abcd".startsWith("bc"); // false "abcd".endsWith("cd"); // true "abcd".endsWith("e"); // false "a".startsWith("a"); // true "a".endsWith("a"); // true 但不幸的是...