String.prototype.startWith = function(s) {
if (s == null || s == "" || this.length == 0 || s.length > this.length)
return false;
if (this.substr(0, s.length) == s)
return true;
else
return false;
return true;
} String.prototype.endWith = function(s) {
if (s == null || s == "" || this.length == 0|| s.length > this.length)
return false;
if (this.substring(this.length - s.length) == s)
return true;
else
return false;
return true;
}
相关文章
- js正则高级函数(replace,matchAll用法),实现正则替换(实测很有效)
- [置顶] 在js中如何实现方法重载?以及函数的参数问题
- 用纯原生js实现jquery的ready函数(两种实现)
- JS实现使用Math.random()函数生成n到m间的随机数字
- js计时函数实现秒表的开始-暂停-清零功能
- 【前端】Util.js-ES6实现的常用100多个javaScript简短函数封装合集(持续更新中)
- JS函数 编程练习 使用javascript代码写出一个函数:实现传入两个整数后弹出较大的整数。
- 【前端】Util.js-ES6实现的常用100多个javaScript简短函数封装合集(持续更新中)
- js函数模拟实现a标签的点击实现href
- 原生JS实现call,apply,bind函数