javascript - How to convert a Set to an Array in Chrome? -
how convert set array? gives 3 answers converting set array, none of work in chrome browser.
let's have simple set
var set_var = new set(['a', 'b', 'c']);
i can iterate through variable , add elements empty array
var array_var = []; set_var.foreach(function(element){array_var.push(element)});
but there other ways have wider browser support?
why not give try set iterator?
function settoarray(set) { var = set.values(), ar = [], ele = it.next(); while(!ele.done) { ar.push(ele.value); ele = it.next(); } return ar; } settoarray(new set(['a', 'b', false, 0, 'c'])); // ["a", "b", false, 0, "c"]
Comments
Post a Comment