This is supported in node.js and newer environments.
var obj = {a: "a", b: "b"};
Object.keys(obj).length // 2
More Related Contents:
- the value of the property “if” is null or undefined, not a Function object [closed]
- How do I remove a property from a JavaScript object?
- Dynamically access object property using variable
- How to use a variable for a key in a JavaScript object literal?
- Test for existence of nested JavaScript object key
- Sorting object property by values
- How to create an object property from a variable value in JavaScript? [duplicate]
- Remove array element based on object property
- Is it possible to get the non-enumerable inherited property names of an object?
- Getting the object’s property name
- How to set a Javascript object values dynamically?
- Access object properties within object [duplicate]
- Access JavaScript property case-insensitively?
- Watch for object properties changes in JavaScript [duplicate]
- create object using variables for property name [duplicate]
- how to access object property using variable [duplicate]
- Can a JavaScript object property refer to another property of the same object? [duplicate]
- How do I access properties of a javascript object if I don’t know the names?
- Get object property name as a string
- How to create Javascript constants as properties of objects using const keyword?
- Accessing an object property with a dynamically-computed name
- How to prevent automatic sort of Object numeric property?
- Are there limits to the number of properties in a JavaScript object?
- Dynamically Add Variable Name Value Pairs to JSON Object
- What is the difference between ( for… in ) and ( for… of ) statements?
- What does [object Object] mean?
- iterating through object
- Using jQuery to compare two arrays of Javascript objects
- JavaScript Extending Class
- Safely parsing a JSON string with unquoted keys