js判断字符串是否为空,多个空格也算为空

String.prototype.trim = function () {
        return this.replace(/(^\s*)|(\s*$)/g, '');
 }

function isEmpty(obj) {
     if (typeof obj === "undefined" || obj == null || obj.trim() == "") {
            return true;
      } else {
            return false;
      }
}

猜你喜欢

转载自www.cnblogs.com/yongfengnice/p/11060926.html