Js判断对象是否为空,Js判断字符串是否为空

Js判断对象是否为空,Js判断字符串是否为空,JS检查字符串是否为空字符串

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

蕃薯耀 2016年4月19日 10:30:24 星期二

http://fanshuyao.iteye.com/

/**
* 去掉字符串头尾空格
* @param str 传入的字符串值
* @author lqy
* @since 2015-08-21
*/
function trim(str) {
	if(str == null || typeof str == "undefined"){
		return "";
	}
    return str.replace(/(^s*)|(s*$)/g, "");
};

/**
 * 是否为Null
 * @param object
 * @returns {Boolean}
 */
function isNull(object){
	if(object == null || typeof object == "undefined"){
		return true;
	}
	return false;
};

/**
 * 是否为空字符串,有空格不是空字符串
 * @param str
 * @returns {Boolean}
 */
function isEmpty(str){
	if(str == null || typeof str == "undefined" || 
			str == ""){
		return true;
	}
	return false;
};

/**
 * 是否为空字符串,全空格也是空字符串
 * @param str
 * @returns {Boolean}
 */
function isBlank(str){
	if(str == null || typeof str == "undefined" || 
			str == "" || trim(str) == ""){
		return true;
	}
	return false;
};

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

蕃薯耀 2016年4月19日 10:30:24 星期二

http://fanshuyao.iteye.com/

原文地址:https://www.cnblogs.com/fanshuyao/p/6227137.html