How to convert Object's array to an array using JavaScript ? Last Updated : 30 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Given an array of objects and the task is to convert the object values to an array with the help of JavaScript. There are two approaches that are discussed below: Approach 1:We can use the map() method and return the values of each object which makes the array. Example: html <!DOCTYPE HTML> <html> <head> <title> Convert a JS object to an array using JQuery </title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP"></p> <button onclick="myGFG()"> Click Here </button> <p id="GFG_DOWN"></p> <script> var up = document.getElementById("GFG_UP"); var JS_Obj = { 1: ['gfg', 'Gfg', 'gFG'], 2: ['geek', 'Geek', 'gEEK'] }; up.innerHTML = "Object - [" + JSON.stringify(JS_Obj) + "]"; var down = document.getElementById("GFG_DOWN"); function myGFG() { var array = $.map(JS_Obj, function (val, ind) { return [val]; }); down.innerHTML = array; } </script> </body> </html> Output: Utilizing the map() Method to Extract and Display Values from Each Object within an ArrayApproach 2: The Object.keys() method is used to get the keys of object and then those keys are used to get the values of the objects from the array. Example: html <!DOCTYPE HTML> <html> <head> <title> Convert a JS object to an array using JQuery </title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP"></p> <button onclick="myGFG()"> Click Here </button> <p id="GFG_DOWN"></p> <script> var up = document.getElementById("GFG_UP"); var JS_Obj = { 1: ['gfg', 'Gfg', 'gFG'], 2: ['geek', 'Geek', 'gEEK'] }; up.innerHTML = "Object - [" + JSON.stringify(JS_Obj) + "]"; var down = document.getElementById("GFG_DOWN"); function myGFG() { var arr = Object.keys(JS_Obj) .map(function (key) { return JS_Obj[key]; }); down.innerHTML = arr; } </script> </body> </html> Output: Using the Object.keys() Method to Extract and Display Object Keys and Values Comment More infoAdvertise with us Next Article How to convert an object to string using JavaScript ? P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to convert an object to string using JavaScript ? To convert an object to string using JavaScript we can use the available methods like string constructor, concatenation operator etc. Let's first create a JavaScript object. JavaScript // Input object let obj_to_str = { name: "GeeksForGeeks", city: "Noida", contact: 2488 }; Examp 4 min read How to convert a DOM nodelist to an array using JavaScript ? NodeList objects are the collection of nodes, usually returned by properties such as Node.childNodes and methods such as document.querySelectorAll(). Although NodeList is not an actual Array but it is possible to iterate over it with the help of forEach() method. NodeList can also be converted into 2 min read How to Convert Array into Array of Objects using map() & reduce() in JavaScript? An array of objects can contain multiple objects with the same properties i.e. key-value pairs. But a map does not contain duplicate values which means if you convert an array of objects with duplicate objects into a map, it will contain only the unique key-value pairs. Below are the approaches to c 2 min read How to convert Integer array to String array using JavaScript ? The task is to convert an integer array to a string array in JavaScript. Here are a few of the most used techniques discussed with the help of JavaScript. Approaches to convert Integer array to String array:Table of ContentApproach 1: using JavaScript array.map() and toString() methodsApproach 2: Us 2 min read JavaScript - Convert an Array to an Object Here are some common methods which can be used to convert an array to an object: 1. Using JavaScript Object.assign() method The first approach is using the Object.assign() method. This method copies the values of all enumerable properties from source objects(one or more) to a target object.JavaScrip 3 min read How to Convert Object to Array in JavaScript? In this article, we will learn how to convert an Object to an Array in JavaScript. Given an object, the task is to convert an object to an Array in JavaScript. Objects and Arrays are two fundamental data structures. Sometimes, it's necessary to convert an object to an array for various reasons, such 4 min read Like