Last Updated : Jan 1, 2023
Let us understand our today’s article now.
As, there are many ways to convert object to array like object.keys(), object.values() and object.entries().
Here, there are different ways but the method or say pattern remain same.
You can use any from them for conversion. Let us see the codes for better understanding.
The code is as:
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
- Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
- After this, we again create three constants resultName, resultValues and resultEntries. And here first one is created to show keys with help of arrays, the second one is used for values of keys and last is used to show full entries here.
- Inside all, we write their respective codes like object.keys for keys, object.values for values and object.entries for entries. We use them of our values and use in resultName, resultValues and resultEntries respectively.
- Now, at last to see the outputs we directly print them in console usin comsole.log() can be seened with help of inspecting our source page. Then go to console tab to see the output. We hope that you understand this codes properly.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.