js判断对象为空
2016-06-21 13:50
429 查看
http://www.jb51.net/article/42713.htm
其中 isEmptyObject
var isEmptyValue = function(value) { var type; if(value == null) { // 等同于 value === undefined || value === null return true; } type = Object.prototype.toString.call(value).slice(8, -1); switch(type) { case 'String': return !$.trim(value); case 'Array': return !value.length; case 'Object': return $.isEmptyObject(value); // 普通对象使用 for...in 判断,有 key 即为 false default: return false; // 其他对象均视作非空 } };
其中 isEmptyObject
function isEmptyObject(e) { var t; for (t in e) return !1; return !0 }
相关文章推荐
- 原生态js ajax回顾
- 图解Javascript原型链
- jsp中的input
- js动画
- JavaScript库
- js数组高效去重
- JS中IP地址与整数的相互转换
- Javascript实现图片加载从模糊到清晰显示的方法
- Javascript类型系统之String字符串类型详解
- 原生JS封装ajax方法
- JS模仿腾讯图片站的图片翻页按钮效果完整实例
- JS实现简单的右下角弹出提示窗口完整实例
- Chrome 中的 JavaScript 断点设置和调试技巧
- javascript类型系统——字符串String类型
- javascript是判断对象是否是数组
- js跨框架获取html属性值
- JS图片定时翻滚效果实现方法
- Javascript删除指定元素节点的方法
- JSP和JS的区别
- json,xml,Html解析