jQuery $.isEmptyObject vs ES6 Object.keys().length

Benchmark created on


Preparation HTML

<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>

Setup

var fruits = {
  'Allahabadi': 1, 'Annona': 1,     'Annonaceae': 1,
  'Apricot': 1,    'Arbutus': 1,    'Aristotelia': 1,
  'Asimina': 1,    'Asimina': 1,    'Atriplex': 1,
  'Averrhoa': 1,   'Banana': 1,     'Banana melon': 1,
  'Banana': 1,     'Breadfruit': 1, 'Burchellia': 1,
  'Bush tomato': 1,'Cherimoya': 1,  'Chrysophyllum': 1,
  'Citrus': 1,     'Clausena': 1,   'Clymenia': 1,
  'Cornus': 1,     'Couepia': 1,    'Crataegus': 1,
  'Date-plum': 1,  'Diospyros': 1,  'Eugenia': 1,
  'Ficus': 1,      'Fig': 1,        'Fruit hat': 1,
  'Gac': 1,        'Garcinia': 1,   'Gaya': 1,
  'Glycosmis': 1,  'Grape': 1,      'Guava': 1,
  'Honeydew': 1,   'Honeydew': 1,   'Kajari': 1,
  'Kapei': 1,      'Kawachi': 1,    'Kinkoji': 1,
  'Kinkoji': 1,    'Kobayashi': 1,  'Koji orange': 1,
};
// https://en.wikipedia.org/wiki/Category:Edible_fruits


var state;

Test runner

Ready to run.

Testing in
TestOps/sec
Object.keys().length
state = Object.keys(fruits).length;
ready
$.isEmptyObject
state = $.isEmptyObject(fruits);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.