By using Object.values, we can get the values of the object. This method will return an array that contains the object’s own enumerable property values. The order of the returned values is the same as the order that it occurs in the for…in loop.
Object.values(obj)
let employee = {companyName : "Educative"};let manager = Object.create(employee);manager.name = "Ram";manager.designation = "Manager";manager.getName = function(){return this.name;}manager[Symbol("symbol")] = "symbol";Object.defineProperty(manager, "non-enumerable", {enumerable: false})console.log("The manager object is ", manager);console.log("\nValues of the manager object is ", Object.values(manager))// the values of non-enumerable properties,symbols and inherited properties are not included in the keys
In the above code, we have:
manager object from the employee object.symbol as a property key to the manager object.non-enumerable property to the manager object.When we call the Object.values method by passing the manager object as an argument, we will get an array of its own object property values. The returned array doesn’t include the values of:
employee object properties are inherited properties, so those property values are not included.non-enumerable property of manager object.