Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for How do I test for an empty JavaScript object?

Current License: CC BY-SA 4.0

20 events
when toggle format what by license comment
Mar 20, 2023 at 13:40 history edited Kamil Kiełczewski CC BY-SA 4.0
deleted 37 characters in body
Mar 20, 2023 at 11:43 history edited Kamil Kiełczewski CC BY-SA 4.0
deleted 98 characters in body
Mar 20, 2023 at 11:15 history edited Kamil Kiełczewski CC BY-SA 4.0
added 181 characters in body
Mar 20, 2023 at 11:10 history edited Kamil Kiełczewski CC BY-SA 4.0
added 181 characters in body
Mar 20, 2023 at 10:52 history edited Kamil Kiełczewski CC BY-SA 4.0
added 792 characters in body
Mar 14, 2023 at 8:31 comment added dumbass Moronix has better benchmarks than this. Most of those snippets are not remotely equivalent, so it makes little sense to compare them. (K) and (L) are basically the same code, though (with the former missing a return true), yet one is 25% slower than the other... which suggests the differences are so minute anyway that it shouldn’t matter, they are going to be dwarfed by the cost of a function call in which they will be inevitably wrapped, by JIT and garbage collection jitter and other noise.
Jan 11, 2023 at 23:35 comment added kcpr I created a fork of the test changing the initial object to contain 10000 elements and the results are really different: jsbench.me/hplcsahs9e/1 . At least in Firefox and Chromium Object.values clearly wins, which confirms my other test result: jsben.ch/a3bT7 . Thank You anyway! I just believe the answer requires editing.
Aug 4, 2022 at 21:09 comment added Christian @ChristianMatthew with the exception of B-E, everything else should go into its own function anyway...they're too verbose otherwise.
Jul 22, 2022 at 14:49 comment added Valen @Christian Matthew Okay, (o => { for(let k in o) return false; return true; })(obj)
Apr 26, 2022 at 21:42 history edited Akaisteph7 CC BY-SA 4.0
clarify mismatch between table and photo
Sep 22, 2021 at 5:22 history edited Gershom Maes CC BY-SA 4.0
deleted 97 characters in body
S Sep 9, 2021 at 5:23 history suggested Community Bot CC BY-SA 4.0
corrected spelling, fixed grammar, improved formatting
Sep 9, 2021 at 1:42 review Suggested edits
S Sep 9, 2021 at 5:23
Jul 8, 2021 at 17:25 history edited Kamil Kiełczewski CC BY-SA 4.0
added 209 characters in body
May 6, 2021 at 9:34 history edited Kamil Kiełczewski CC BY-SA 4.0
added 84 characters in body
S Mar 29, 2021 at 16:16 history suggested Looky1173 CC BY-SA 4.0
Fixed grammar.
Mar 29, 2021 at 14:57 review Suggested edits
S Mar 29, 2021 at 16:16
Jun 13, 2020 at 0:08 comment added Madacol For completeness, I edited your jsperf to test obj = {a:1,b:2,c:3} and for(var i in obj) is still the fastest jsperf.com/object-empty-ch/2
Apr 10, 2020 at 7:32 comment added Christian Matthew a lot of this doesn't make sense because you're basing everything on a return of false and or true. Sometimes programming needs an if statement or a ternary operator. just fyi
Jan 17, 2020 at 12:53 history answered Kamil Kiełczewski CC BY-SA 4.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /