Set to Array in JS or JavaScript Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report This article will show you how to convert a Set to an Array in JavaScript. A set can be converted to an array in JavaScript in the following ways:1. Using Spread OperatorThe JavaScript Spread Operator can be used to destructure the elements of the array and then assign them to a new variable in the form of an array. JavaScript let s = new Set(['GFG', 'JS']); let a = [...s]; console.log(a); Output[ 'GFG', 'JS' ] 2. Using Array.from() JavaScript Array.from() Method returns a new Array from an array, object or other iterable objects like Map, Set, etc. It takes the set as parameter and converts it to an array. JavaScript const s = new Set([1, 1, 2, 3, 4, 4, 5, 6, 5]); let a = Array.from(s); console.log(a); Output[ 1, 2, 3, 4, 5, 6 ] 3. Using forEach() MethodThe arr.forEach() method calls the provided function once for each element of the set where they are pushed to an array using the push() method. JavaScript let s = new Set(['GFG', 'JS']); let a = []; let fun = function (val1) { a.push(val1); }; s.forEach(fun); console.log(a); Output[ 'GFG', 'JS' ] 4. Using Lodash _.toArray() MethodLodash is an JavaScript library that allows us to use the _.toArray() method which accepets a value and convert it to an array.NOTE: To use this approach, you need to install the lodash library into your local system using the npm i lodash command. JavaScript // Requiring the lodash library const _ = require("lodash"); let s = new Set(['welcome', 'to', 'GFG']); // Use of _.toArray() method console.log(_.toArray(s)); Output:Set Elements: Set(3) { 'welcome', 'to', 'GFG' }Array Elements: [ 'welcome', 'to', 'GFG' ]));)); Comment More info K kartikgoel1999 Follow Improve Article Tags : JavaScript Web Technologies javascript-array JavaScript-DSA JavaScript-Questions JavaScript-Set +2 More Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings6 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in Javascript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readJavascript Scope3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like