
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to convert dictionary into list of JavaScript objects?
Following is the code to convert dictionary into list of JavaScript objects −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample{ font-size: 18px; font-weight: 500; color: rebeccapurple; } </style> </head> <body> <h1>Convert dictionary into list of JavaScript objects</h1> <div class="sample"> { A: { 1: "Apple", 2: "Apricot" }, B: { 1: "Ball", 2: "Bull" }, C: { 1: "Cat", 2: "Cow" }, D: { 1: "Dog", 2: "Drill" }, } </div> <button class="Btn">CLICK HERE</button> <h3>Click the above button to convert the above dictionary into list of object</h3> <script> let BtnEle = document.querySelector(".Btn"); let arr; const obj = { A: { 1: "Apple", 2: "Apricot" }, B: { 1: "Ball", 2: "Bull" }, C: { 1: "Cat", 2: "Cow" }, D: { 1: "Dog", 2: "Drill" }, }; BtnEle.addEventListener("click", () => { arr = Object.values(obj); console.log(arr); }); </script> </body> </html>
Output
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button and looking at the output in console −
- Related Articles
- Python program to convert a list of tuples into Dictionary
- How to convert a list collection into a dictionary in Java?
- Python - Convert list of nested dictionary into Pandas Dataframe
- How to convert Javascript dictionary to Python dictionary?
- How to convert Python Dictionary to a list?
- How to convert list to dictionary in Python?
- How to convert array into array of objects using map() and reduce() in JavaScript
- Python Convert nested dictionary into flattened dictionary?
- Python - Convert flattened dictionary into nested dictionary
- Convert an array of objects into plain object in JavaScript
- Convert dictionary to list of tuples in Python
- How we can convert Python objects into JSON objects?
- How to convert a DataFrame into a dictionary in Pandas?
- Python - Convert a set into dictionary
- Convert 2d tabular data entries into an array of objects in JavaScript

Advertisements