原生javascript判断当前对象是否为空
/**
* 判断当前对象是否为空
*
* @method isEmpty
* @param {Object}
* obj
* @return {Boolean} empty 当为 null,undefined,"" 将返回true
*/
window.isEmpty = function(obj) {
return (obj == null || typeof obj == "undefined" || obj.length == 0)
}
/**
* 判断当前对象是否非空
*
* @method isNotEmpty
* @param {Object}
* obj
* @return {Boolean}
*/
window.isNotEmpty = function(obj) {
return !isEmpty(obj);
}
如果您觉得本文的内容对您的学习有所帮助:
关键字:
javascript 正则表达式 获取参数值 function 对象是否为空