Navigate back to the homepage

How to convert object values to array in typescript?

April 9th, 2022 · 1 min read
keep affilitate

Hi Friends 👋,

Welcome to Infinitbility ❤️!

Today, I’m going to show you how to convert object values to array in typescript, here we use some javascript Objects method like Object.values() method.

Sometime’s we need to create array from object values and that’s why we simple method Object.values()

1interface User {
2 id: number;
3 name: string;
4 domain?: string;
5 age?: number;
6 isActive?: boolean;
9let user: User = {
10 id: 1,
11 name: "infinitbility",
12 domain: "",
13 age: 2,
14 isActive: 1
17let userKeys = Object.values(user).map(key => {return key});

When you run above code you will get all your objects property in array, check below output image.


TypeScript, convert object values to array example
TypeScript, convert object values to array example

All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

melio affilitate

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide



More articles from Infinitbility

How to convert object to array in typescript?

TypeScript, convert object to array example.

April 8th, 2022 · 1 min read

How to convert string to date in typescript?

TypeScript, convert string to date object example.

April 6th, 2022 · 1 min read
© 2020–2022 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]