I have a JavaScript object like
var obj = {
key1: \'value1\',
key2: \'value2\',
key3: \'value3\',
key4: \'value4\'
}
How can I
In JavaScript, an object is a standalone entity, with properties and type.
For fetching values from Object in form of array: Object.values(obj) // obj is object name that you used Result -> ["value1", "value2", "value3", "value4"]
For fetching keys from Object in form of array: Object.keys(obj) // obj is object name that you used Result -> ["key1", "key2", "key3", "key4"]
As both functions are returning array you can get the length of keys or value by using length property. For instance - Object.values(obj).length or Object.keys(obj).length