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?
Similar Posts
- Get all values from an array which does not exist in other array Lodash
- Check if all array items are equal javascript
- Get all keys from an object using Javascript
- Javascript to convert all object keys to lowercase
- Remove all false, null, undefined and empty values from array using Lodash
- Get the sum of array values using Javascript - Solved
- Assign items of arrays to multiple variable when creating it (Array Destructuring) Javascript(ES6)