判断是否以某个指定字符串结尾或开头
- startsWith: 字符串以什么开头, 返回布尔值
- endsWidth: 字符串以什么结尾, 返回布尔值
- lastIndexOf: 从后往前找, 第二个参数可以指定从哪个索引往前找, 返回索引或-1
('www.baidu.com').startsWidth('www') //true
('www.baidu.com').startsWidth('baidu') //false
('www.baidu.com').endsWidth('com') //true
('www.baidu.com').endsWidth('baidu') //false
('www.baidu.com').lastIndexOf('b',4) //从第四个索引往前找, 包括4, 返回为4
('www.baidu.com').lastIndexOf('b',3) //返回 -1
('www.baidu.com').lastIndexOf('c') //从后往前找, 10