let animal = {head: 1};
Object.defineProperty(animal, 'legs', {value: 4});
This object has two properties, but your code above will return 1. So my thought was that it's better to replace Object.keys with Object.getOwnPropertyNames to return correct amount of an object's total properties.
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.
Which part? Hmm...i don't think i see it π²
Here's your code in the end of the article to count total amount of an object's properties.
Let's take a look at this object:
This object has two properties, but your code above will return 1. So my thought was that it's better to replace
Object.keys
withObject.getOwnPropertyNames
to return correct amount of an object's total properties.