[JavaScript] JavaScript判断前缀、后缀和是否全是空格 →→→→→进入此内容的聊天室

来自 , 2019-10-24, 写在 JavaScript, 查看 163 次.
URL http://www.code666.cn/view/eba237ec
  1. // Js 判断后缀
  2. String.prototype.endsWith = function(suffix) {  
  3.     return this.indexOf(suffix, this.length - suffix.length) !== -1;  
  4. };  
  5.  
  6. // Js 判断前缀
  7. if (typeof String.prototype.startsWith != 'function') {
  8.   // see below for better implementation!
  9.   String.prototype.startsWith = function (str){
  10.     return this.indexOf(str) == 0;
  11.   };
  12. }  
  13.    
  14. // Js 判空(含全部是空格)
  15. String.prototype.IsNullEmptyOrSpace = function()  
  16. {  
  17.    if (this== null) return true;  
  18.       return this.replace(/s/g, '').length == 0;  
  19. };  
  20. //javascript/6775

回复 "JavaScript判断前缀、后缀和是否全是空格"

这儿你可以回复上面这条便签

captcha