Get the length of the keys on an object. Much faster than Object.keys()
If you need the length of an object's properties, excluding prototype properties, use object-length
Install with npm
npm i keys-length --save
var len = require('keys-length');
len({a: 'b', c: 'd', e: 'f'});
//=> 3
- expand-object: Expand a string into a JavaScript object using a simple notation.
- object-length: Get the length of an object's properties, excluding prototype properties. Works with dontEnum bugs.
#1: 2 keys
'for-in loop' x 24,570,016 ops/sec ±0.65% (93 runs sampled)
'Object.keys()' x 3,840,164 ops/sec ±0.62% (97 runs sampled)
#2: 5 keys
'for-in loop' x 22,487,684 ops/sec ±0.83% (91 runs sampled)
'Object.keys()' x 3,169,150 ops/sec ±0.59% (97 runs sampled)
#3: 10 keys
'for-in loop' x 20,201,512 ops/sec ±1.06% (94 runs sampled)
'Object.keys()' x 2,519,700 ops/sec ±0.62% (94 runs sampled)
#4: 52 keys
'for-in loop' x 10,519,640 ops/sec ±0.61% (97 runs sampled)
'Object.keys()' x 791,094 ops/sec ±0.63% (94 runs sampled)
Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 12, 2015.