How to Get all Property Values of a JavaScript Object without knowing the Keys? Last Updated : 14 Oct, 2024 Comments Improve Suggest changes Like Article Like Report To get all property values from a JavaScript object without knowing the keys involves accessing the object's properties and extracting their values.Below are the approaches to get all property values of a JavaScript Object:Table of ContentUsing Object.values() MethodUsing Object.keys() methodApproach 1: Using Object.values() Method The Object.values() method is used to return an array of the object's own enumerable property values. The array can be looped using a for-loop to get all the values of the object. Therefore, the keys are not required to be known to get all the property values. Syntax:let valuesArray = Object.values(exampleObj);for (let value of valuesArray) { console.log(value);}Example: This example shows the use of the above-explained approach. JavaScript let exampleObj = { language: "JavaScript", designedby: "Brendan Eich", year: "1995" }; let valuesArray = Object.values(exampleObj); for (let value of valuesArray) { console.log(value); } OutputJavaScript Brendan Eich 1995 Approach 2: Using Object.keys() methodThe Object.keys() method is used to return an array of objects own enumerable property names. The forEach() method is used on this array to access each of the keys. The value of each property can be accessed using the keys with an array notation of the object. Therefore, the keys are not required to be known beforehand to get all the property values. Syntax:let objKeys = Object.keys(exampleObj);objKeys.forEach(key => { let value = exampleObj[key]; console.log(value);});Example:This example shows the implementation of the above-explained approach. JavaScript let exampleObj = { language: "JavaScript", designedby: "Brendan Eich", year: "1995" }; let objKeys = Object.keys(exampleObj); objKeys.forEach(key => { let value = exampleObj[key]; console.log(value); }); OutputJavaScript Brendan Eich 1995 Comment More infoAdvertise with us Next Article How to Get all Property Values of a JavaScript Object without knowing the Keys? S sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to get a subset of a javascript object's properties? To get the subset of properties of a JavaScript Object, we make use of destructuring and Property Shorthand. The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.Syntax: subset = (({a, 2 min read How to get all the methods of an object using JavaScript? In this article, we will learn how to get all the methods of an object using JavaScript. In JavaScript, we can get all the methods of an object by iterating over each object and checking if its property value is a function. An HTML document contains some methods and the task is to get all methods of 2 min read How to get the first key name of a JavaScript object ? In JavaScript, accessing the first key name of an object involves identifying the initial property defined within that object. This concept is useful when you need to interact with or manipulate object properties in a specific order, particularly when the sequence of properties is relevant.Here we h 2 min read How to get the Last Nested Property Using JavaScript ? The last nested property in JavaScript is the innermost property within a hierarchy of nested objects, which can be accessed by traversing through the object. These are the following ways to get the last nested property using JavaScript: Table of Content Using recursionUsing Array.is() methodMethod 2 min read How to unflatten an object with the paths for keys in JavaScript ? In this article, we will learn to unflatten an object which has a certain number of key-value pairs(s) within it with the paths for the keys in JavaScript. Problem Statement: You are given an object with several key-value pair(s). Some keys have various keys names present after a dot, you basically 4 min read Like