You can use Object.keys() and map() to do this
var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
var result = Object.keys(obj).map((key) => [key, obj[key]]);
console.log(result);
Answer from Nenad Vracar on Stack Overflow Top answer 1 of 16
748
You can use Object.keys() and map() to do this
var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
var result = Object.keys(obj).map((key) => [key, obj[key]]);
console.log(result);
2 of 16
350
The best way is to do:
var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
var result = Object.entries(obj);
console.log(result);
Calling entries, as shown here, will return [key, value] pairs, as the caller requested.
Alternatively, you could call Object.values(obj), which would return only values.
GeeksforGeeks
geeksforgeeks.org โบ javascript โบ how-to-convert-an-object-into-array-of-objects-in-javascript
How to Convert an Object into Array of Objects in JavaScript? - GeeksforGeeks
July 23, 2025 - Object.values() method extracts the property values of an object and returns them as an array, converting the original object into an array of objects.
JavaScript Tutorial
javascripttutorial.net โบ home โบ convert an object to an array in javascript
Convert an Object to an Array in JavaScript
March 29, 2020 - To convert the enumerable string-keyed properties of an object to an array, you use the Object.entries() method.
OneCompiler
onecompiler.com โบ javascript โบ 3ww4b7q6d
Convert Key, Values in an Object to Array - JavaScript - OneCompiler
//Object spread const post = { ...options, type: "new", } //array spread const users = [...adminUsers, ...normalUsers]
YouTube
youtube.com โบ shorts โบ EaEw3PU1bN4
Convert Object to Array in JavaScript: Quick & Easy Trick - YouTube
"In this short, learn how to quickly convert an object to an array in JavaScript with a simple method. Whether you're working with Object.keys(), Object.valu...
Published: October 23, 2024
OneCompiler
onecompiler.com โบ javascript โบ 3ww3ua972
Converting Objects to Arrays - JavaScript - OneCompiler
//Object spread const post = { ...options, type: "new", } //array spread const users = [...adminUsers, ...normalUsers]
Javatpoint
javatpoint.com โบ convert-object-to-array-in-javascript
Convert object to array in Javascript - Javatpoint
Convert object to array in Javascript - Convert object to array in Javascript with javascript tutorial, introduction, javascript oops, application of javascript, loop, variable, objects, map, typedarray etc.
Call: +917738666252
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
TutorialsPoint
tutorialspoint.com โบ article โบ how-to-convert-an-object-into-an-array-in-javascript
How to convert an object into an array in JavaScript?
March 15, 2026 - The Object.keys() method returns an array of an object's property names: const student = { name: "Chris", age: 25, marks: 85, city: "New York" }; const keysArray = Object.keys(student); console.log(keysArray); ... const student = { name: "Chris", ...
YouTube
youtube.com โบ watch
How To Convert An Object To An Array In Javascript - YouTube
Hey guys, it's been quite a while since I last uploaded but I'm going to start uploading more tutorial-style videos, I promise! Sorry about the mic quality, ...
Published: January 24, 2023
ServiceNow Community
servicenow.com โบ community โบ developer-forum โบ please-suggest-how-to-convert-object-to-array-in-javascript โบ m-p โบ 2657108
Please suggest how to convert object to array in javascript
August 30, 2023 - To convert an ordinary object that's not iterable or array-like to an array (by enumerating its property keys, values, or both), use Object.keys() , Object.values() , or Object.entries() . To convert an async iterable to an array, use Array.fromAsync() .
Scaler
scaler.com โบ home โบ topics โบ convert an object to an array in javascript
Convert an Object to an Array in JavaScript - Scaler Topics
October 17, 2023 - In JavaScript, dealing with an object having a long list of properties can be challenging, for example - printing all values into the object requires iterating over the object and printing the individual key-value. To make the object easy to use, we have Object methods that give the power to convert object to array javascript.
MDN Web Docs
developer.mozilla.org โบ en-US โบ docs โบ Web โบ JavaScript โบ Reference โบ Global_Objects โบ Array โบ from
Array.from() - JavaScript - MDN Web Docs
The Array.from() static method creates a new, shallow-copied Array instance from an iterable or array-like object.
GeeksforGeeks
geeksforgeeks.org โบ javascript โบ how-to-convert-an-object-to-an-array-of-key-value-pairs-in-javascript
Convert an Object to JavaScript Array - GeeksforGeeks
August 19, 2026 - The simplest approach is to use the Object.entries() method, which directly returns an array containing the object's own enumerable key-value pairs. ... let obj = { a: 1, b: 2, c: 3 }; // Convert object into an array of key-value pairs let result ...