Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Iterate over values of an object with ES2017 Object.values()


    This lesson take an extensive look at the addition of the Object.values functions, how they can be used to gather information about the values of an object’s own enumerable string-key properties



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: Let's look at the object.values method that's introduced in ES2017. Let's describe our day using an object. We'll add in properties like wake-up time and make it equal to the new date. Let's also add a list of gadgets, laptop and phone.

    Now, let's capture the actual values from the object using object.values method. Here, we'll pass in our day object. Then, we'll go ahead and log the values that we have captured. Now, let's go to the terminal and run our index file in node.

    You can see that it outputs a list of objects. You can see that the first one is the value of wake-up time that is the new date, and the second one is the value of gadgets that is the array of laptop and phone.

    Let's test the same for functions. We'll add a function called as goToWork and we'll simply console log work inside it. Now, if we go ahead and run this file in node, you can see that it outputs a function with the name goToWork in the list of objects.