const entries = [
['foo', 'bar'],
['baz', 42]
];
Object.fromEntries(entries)
// object.fromEntries Explain
// Note : it's work with array of an array
let name =['noor','alex','biker','hosler']
let ages = [ 11 , 13 , 15 , 17];
const newvalue=(
name.map((nameArrayElement,index)=>{
return [nameArrayElement,ages[index]]
})
)
console.log(newvalue);
// output without using fromEntries
// [ [ 'noor', 11 ], [ 'alex', 13 ], [ 'biker', 15 ], [ 'hosler', 17 ] ]
const newvalueAfterFromEntries=Object.fromEntries(
name.map((nameArrayElement,index)=>{
return [nameArrayElement,ages[index]]
})
)
console.log(newvalueAfterFromEntries);
// Output AfterFromEntries
// { noor: 11, alex: 13, biker: 15, hosler: 17 }
// BY Noor Mohammad Patwary