Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

one array to another arrays value javascript

// 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

 
PREVIOUS NEXT
Tagged: #array #arrays #javascript
ADD COMMENT
Topic
Name
4+1 =