How to Get Values of a Javascript Object with Object.values()

Published on October 1, 2019

Use-Cases of this Tutorial

  • Know how to get all values of a Javascript object.
  • Know about the Object.values() method.

All property values of a Javascript object can be found with the Object.values() method.


Object.values() returns an array of all values of object's own enumerable property names.

Enumerable properties of an object have their "enumerable" attribute set to "true" (by default this is "true" when a new property is added to the object).

Own enumerable properties are owned by the object and not by an other object in its prototype chain (In Javascript inheritance happens through prototypes).

Example #1 :

var student = {
	name: "John Wick",
	age: 27,
	gender: "M"

var values = Object.values(student);

// [ "John Wick", 27, "M" ]

Example #2 :

// create objects using constructor function
function Student(name, age, gender) { = name;
	this.age = age;
	this.gender = gender;

Student.prototype = {
	city: "Pisa",
	country: "Italy"

// new object
var student_1 = new Student("John Wick", 27, "M");

var values = Object.values(student_1);


// [ "John Wick", 27, "M" ]
// "Pisa" and "Italy" will not be included as the belong to its prototype
In this Tutorial