Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

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

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

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

    Akash GuthaAkash Gutha

    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

    javascriptJavaScript
    Code

    Code

    Become a Member to view code

    You must be a 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
    Transcript

    Transcript

    Instructor: 00:00 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.

    00:17 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.

    00:36 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.

    00:51 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.

    Discuss

    Discuss