I think Object.values and Object.keys will have the same length, as they both consider only enumerable properties:
Object.values
Object.keys
Docs for Object.values
true story...
const object1 = { a: 'somestring', b: 42, c: false, [Symbol('ghost')]: '👻' }; console.log(Object.values(object1).length); //>3
I'm getting 3 for the length of both keys and values. The arrays are ["a", "b", "c"] and ["somestring", 42, false], respectively.
3
length
keys
values
["a", "b", "c"]
["somestring", 42, false]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think
Object.valuesandObject.keyswill have the same length, as they both consider only enumerable properties:Docs for Object.values
true story...
I'm getting
3for thelengthof bothkeysandvalues. The arrays are["a", "b", "c"]and["somestring", 42, false], respectively.