title | description | author | tags |
---|---|---|---|
Count Properties in Object |
Counts the number of own properties in an object. |
axorax |
object,count,properties |
function countProperties(obj) {
return Object.keys(obj).length;
}
// Usage:
const obj = { a: 1, b: 2, c: 3 };
countProperties(obj); // Returns: 3