javascript

Get all values as array items from an Object in Javascript

To get all the values from an Object you can use the method Object.values() and pass object to it. It will return the array which contains object values as its items.

const obj = {
    "id": 20,
    "name": "John Deo",
    "dept": "Computer",
    "pincode": "11111"
};

var obj_values = Object.values(obj);
Output
[20,"John Deo","Computer","11111"]

Live Demo

Was this helpful?