i have this array:
const array = [ 'one', 'two', 'three' ]
I'd like to convert this array into an object without indexes. How would this be possible?
i have this array:
const array = [ 'one', 'two', 'three' ]
I'd like to convert this array into an object without indexes. How would this be possible?
Try with Array#forEach() .Iterate the array using foreach and append key and value with in res object
const array = [ 'one', 'two', 'three' ]
var res={}
array.forEach(function(a){
res[a]=a
})
console.log(res)