How to get all object values without loop

Heru Hartanto - May 8 '22 - - Dev Community

Es8 has introduced a new cool feature called Object.values() that can be used to get the values of an object.

with Object.values instead of iterating through every element of object we can use it to return all values an object in array.

    const cars = {
        'Toyota': 'Camry',
        'Ford': 'Fiesta',
        'Honda': 'Civic'
    };
    const carsValue = Object.values(cars);

    //['Camry', 'Fiesta', 'Civic']
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player