`

How to check if object has any properties in JavaScript?

阅读更多
http://stackoverflow.com/questions/2673121/how-to-check-if-object-has-any-properties-in-javascript


function isEmptyObject(obj) {
  for(var prop in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, prop)) {
      return false;
    }
  }
  return true;
}

isEmptyObject({}); // true
isEmptyObject({foo:'bar'});  // false
分享到:
评论

相关推荐

    Packt.Object-Oriented.JavaScript.3rd.Edition

    and make them your own Understand objects in Google Chrome developer tools and how to use Them Use a mix of prototypal inheritance and copying properties in your workflow Apply reactive programming ...

    The Principles of Object-Oriented JavaScript 1st Edition

    It has no concept of classes, and you don't even need to define any objects in order to write code. But don't be fooled—JavaScript is an incredibly powerful and expressive object-oriented language ...

    How to Learn Any Language

    How to Learn Any Language 全英!!!

    How to Check all Checkboxes Using Javascript.zip

    在JavaScript编程领域,"How to Check all Checkboxes Using Javascript.zip" 这个资源包主要聚焦于如何使用JavaScript一次性选中所有复选框(checkboxes)的功能。在网页交互设计中,这种功能常见于用户需要批量...

    how to make sense of any mess

    How to Make Sense of Any Mess: Information Architecture for Everybody Abby Covert Everything is getting more complex. It is easy to be overwhelmed by the amount of information we encounter each ...

    Object Oriented JavaScript(PACKT,3ed,2017)

    and make them your own Understand objects in Google Chrome developer tools and how to use Them Use a mix of prototypal inheritance and copying properties in your workflow Apply reactive programming ...

    Javascript.Object.Oriented.Programming.pdf

    You should read through this course if you want to be able to take your JavaScript skills to a new level of sophistication. Style and approach This course is a comprehensive guide where each chapter...

    How to Create an Object Class in MATLAB.zip

    在提供的资源中,"How to Create an Object Class in MATLAB.mp4"可能是一个视频教程,详细展示了如何实际操作创建对象类的过程,而"How to Create an Object Class in MATLAB - 韩语 中文(简体)(双语).srt"则可能...

    How to do everything with javascript

    "How to do everything with JavaScript" 涵盖了从基础到高级的JavaScript知识,旨在帮助开发者全面理解和掌握这门语言的体系结构及其实际应用。这本书可能包括了变量、数据类型、控制结构、函数、对象、数组、DOM...

    Functional.Programming.in.JavaScript.1784398225

    If you are a JavaScript developer interested in learning functional programming, looking for the quantum leap towards mastering the JavaScript language, or just want to become a better programmer in ...

    JavaScript.Novice.to.Ninja.2nd.Edition

    Comprehensively updated to cover ECMAScript 6 and modern JavaScript development, the second edition of this step-by-step introduction to coding in JavaScript will show you how to to solve real-world ...

    how to solve it

    Polya, "How to Solve It" will show anyone in any field how to think straight. In lucid and appealing prose, Polya reveals how the mathematical method of demonstrating a proof or finding an unknown ...

    JavaScript Object Programming(Apress,2015)

    This brief book explains the advantages of the object model, inheritance, both classical and prototypical, and shows how these concepts can be implemented in JavaScript. It also shows how object ...

    OpenCV_ObjectDetection_HowTo

    the document describes how to build a cascade classifier for object detection with haar features

    javascript面向对象编程指南 2nd

    The basics of object-oriented programming, and how to apply it in the JavaScript environment How to set up and use your training environment (Firebug) In depth discussion of data types, operators, ...

    how to work with crystal report in sap business one

    how to work with crystal report in sap business one

    VTK 12 How to Write a Process__ Object.pdf

    VTK 12 How to Write a Process__ Object.pdf VTK 12 How to Write a Process__ Object.pdf VTK 12 How to Write a Process__ Object.pdf

    JavaScript Functional Programming for JavaScript Developers (PDF, EPUB, MOBI)

    If you are a JavaScript developer interested in learning functional programming, looking for the quantum leap toward mastering the JavaScript language, or just want to become a better programmer in ...

Global site tag (gtag.js) - Google Analytics