$.isPlainObject()

jQuery.isPlainObject()函数的返回值为Boolean类型,如果指定的参数是纯粹的对象,则返回true,否则返回false。

function w( html ){
    document.body.innerHTML += "<br/>" + html;
}
w( $.isPlainObject( { } ) ); // true
w( $.isPlainObject( new Object() ) ); // true
w( $.isPlainObject( { name: "CodePlayer"} ) ); // true
w( $.isPlainObject( { sayHi: function(){} } ) ); // true
w( $.isPlainObject( "CodePlayer" ) ); // false
w( $.isPlainObject( true ) ); // false
w( $.isPlainObject( 12 ) ); // false
w( $.isPlainObject( [ ] ) ); // false
w( $.isPlainObject( function(){ } ) ); // false
w( $.isPlainObject( document.location ) ); // false(在IE中返回true)
function Person(){
    this.name = "张三";
}
w( $.isPlainObject( new Person() ) ); // false
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,867评论 19 139
  • 第5章 引用类型(返回首页) 本章内容 使用对象 创建并操作数组 理解基本的JavaScript类型 使用基本类型...
    大学一百阅读 3,713评论 0 4
  • 在桂子山的两年,是我人生中过得最闲适的一段时光,没有考试,更没有升学的压力,我有充足的时间发掘自己的爱好,更有相对...
    欢喜的海塔阅读 1,059评论 4 17
  • 三十辐 , 共一毂 , 当其无 , 有车之用 。埏埴 以为器 , 当其无 ,有器之用 。凿户牖以为室 ,当其无 ,...
    季悸阅读 510评论 0 0
  • 男: 哽咽:你为了救他竟然选择让我死,我们五年的夫妻情分,竟然如此薄凉,也好,能够死在你手里,我倒也情愿,动手吧!...
    潇潼阅读 17,230评论 2 10

友情链接更多精彩内容