Search code snippets, questions, articles...

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);
[20,"John Deo","Computer","11111"]

Live Demo

Search Index Data (The code snippet can also be found with below search text)

Object.values() javascript
Was this helpful?
Programming Feeds
Learn something new everyday on Devsheet