Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 68
    @Tres - your code can be broken if someone would come and overide the 'size' property without knowing you declared it already somewhere in the code, so it's always worth checking if it's already defined Commented Jun 14, 2011 at 11:30
  • 19
    @vsync You are very correct. One should always implement necessary sanity checks :) Commented Jun 24, 2011 at 2:03
  • 161
    Why is everyone ignoring this: Object.keys(obj).length Commented Feb 25, 2015 at 0:14
  • 37
    @MuhammadUmer Probably because that method didn't even exist when this answer was written. Even today, using it will probably require a polyfill for old browsers. Commented May 9, 2015 at 1:53
  • 26
    @stonyau IE8, IE9, IE10 are dead browsers that don't get support from Microsoft. IE8, IE9, IE10 user gets notification from Microsoft, that they use old, unsupported browser and should expect that stuff will not work for them. support.microsoft.com/en-us/kb/3123303 Commented Jan 19, 2016 at 9:08