清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>> 
                    
1、清除左空格/右空格
function ltrim(s){ return s.replace( /^(\s*| *)/, ""); } 
function rtrim(s){ return s.replace( /(\s*| *)$/, ""); } 
 
2、判断是否以某个字符串开头
String.prototype.startWith = function (s) {
    return this.indexOf(s) == 0
} 
 
3、判断是否以某个字符串结束
String.prototype.endWith = function (s) {
    var d = this.length - s.length;
    return (d >= 0 && this.lastIndexOf(s) == d)
} 
                            