JavaScript .values()
Published Aug 22, 2025
Contribute to Docs
The Object.values() method returns an array containing the values of an object’s own enumerable properties. This method is useful when only the values are needed, not the keys.
Syntax
Object.values(obj)
Parameters:
obj: The object whose own enumerable property values needs to be retrieved.
Return value:
- An array of the object’s own enumerable property values, ordered by integer keys first (ascending), then string keys in insertion order.
Example 1: Basic usage of Object.values()
In this example, Object.values() creates an array of property values from an object:
const teamA = {firstName: 'Liany',animal: 'cat',age: 30,};const values = Object.values(teamA);console.log(values);
This example results in the following output:
["Liany", "cat", 30]
Example 2: Iterating over values
In this example, Object.values() is used with a for...of loop to iterate through numeric values in an object:
const scores = { teamLiany: 100, teamWife: 106, teamPrincess: 142 };for (const value of Object.values(scores)) {console.log(value);}
This example results in the following output:
100106142
Codebyte Example: Object.values() with .filter() method to detect booleans in a config object
In this example, Object.values() is combined with .filter() to extract only boolean values from an object:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
- Beginner Friendly.15 hours