by Sai gowtham

How to get the Object values list in JavaScript

In this tutorial, we will learn about how to get values in the javascript Object.

Object.values( ) method is used to get the enumerable object property values as an array.

let colors = {
    black: "#00000",
    white: "#ffff",
    red: "#FF0000"
}


console.log(Object.values(colors));

// ["#00000", "#ffff", "#FF0000"]


let  emails = {
    user1 : "example1@gmail.com",
    user2 : "example2@gmail.com",
    user3 : "example3@gmail.com",
}

console.log(Object.values(emails));

// ["example1@gmail.com", "example2@gmail.com", "example3@gmail.com"]

Object.values() method takes the object as its first argument and returns the array of object values. The ordering of the values in an array are the same order present in the object.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course