Avatar ·

How to efficiently count the number of keys/properties of an object in JavaScript?

Hi everyone! I'm a beginner JS developer, and I have a problem with counting the number of properties in an object. I have an object that stores user data: ```javascript const users = { user1: { name: 'Alice', age: 30 }, user2: { name: 'Bob', age: 25 }, user3: { name: 'Charlie', age: 35 } }; ``` I need to find out how many users are in this object. I tried using the `.length` property, like with arrays, but it returns `undefined`. I found this method: `Object.keys(users).length`, and it works. But I'm concerned about performance. I might have objects with hundreds or thousands of keys. Will this method be slow? Are there faster ways to count the number of keys? Also, I've heard about the `for...in` loop, but it seems