首页 > 代码库 > 判断Javascript对象是否为空
判断Javascript对象是否为空
判断普通javascript对象是否为空(含有可枚举的属性,自有的、继承的都可以),可使用jQuery 3.2.1版的isEmptyObject()方法:
isEmptyObject: function( obj ) { var name; for ( name in obj ) { return false; } return true; }
As of jQuery 1.4 this method checks both properties on the object itself and properties inherited from prototypes (in that it doesn‘t use hasOwnProperty). The argument should always be a plain JavaScript Object
as other types of object (DOM elements, primitive strings/numbers, host objects) may not give consistent results across browsers. To determine if an object is a plain JavaScript object, use $.isPlainObject()
判断Javascript对象是否为空
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。