convert to array javascript Archives - Tech Insights Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Thu, 14 Sep 2023 07:34:28 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 convert to array javascript Archives - Tech Insights 32 32 230003556 How to Convert Set into an Array in TypeScript https://reactconf.org/how-to-convert-set-into-an-array-in-typescript/ https://reactconf.org/how-to-convert-set-into-an-array-in-typescript/#respond Thu, 14 Sep 2023 07:34:28 +0000 https://labpys.com/?p=1673 In TypeScript, Convert the Set into an Array by using the “Array.from” function or by using the spread operator “(`...`)”. In this article, we will learn How to convert “Set” …

The post How to Convert Set into an Array in TypeScript appeared first on Tech Insights.

]]>
In TypeScript, Convert the Set into an Array by using the “Array.from” function or by using the spread operator “(`...`)”. In this article, we will learn How to convert “Set” into an Array in TypeScript.

convert set into an Array in Typescript

Using Array.from Method

Array.from” the method is used to create a new array from an iterable object.

Here is how you can use Array.from in TypeScript

const setArray = new Set([1001,1020,1400,2300,'Pointing','Stuart']);
const arry = Array.from(setArray);

console.log(arry);

Output:

[ 1001, 1020, 1400, 2300, ‘Pointing’, ‘Stuart’ ]

Using Spread Operator

const setArray = new Set([1001,1020,1400,2300,'Pointing','Stuart']);
const arrspreading = [...setArray];
console.log(arrspreading);

Related article – How to Create a Set in TypeScript

The post How to Convert Set into an Array in TypeScript appeared first on Tech Insights.

]]>
https://reactconf.org/how-to-convert-set-into-an-array-in-typescript/feed/ 0 1673