This is good, anyhow is an antipattern, it should be something like:
constconvertArrayToObject=(array,key)=>array.reduce((acc,curr)=>{acc[curr[key]]=curr;returnacc;},{});// Even conciseconstconvertArrayToObject=(array,key)=>array.reduce((acc,curr)=>(acc[item[key]]=item,acc),{});// Basically everything inside parentheses will be evaluated, only the last value used will be only returned.
In this way, you avoid the spread op which is a way expensive than a single assignment
Thanks for taking the time to help me and others out here! I am going to read up on the Comma operator in JavaScript developer.mozilla.org/en-US/docs/W... do you have any other resources you recomend here?
We're a place where coders share, stay up-to-date and grow their careers.
This is good, anyhow is an antipattern, it should be something like:
In this way, you avoid the spread op which is a way expensive than a single assignment
Thanks for taking the time to help me and others out here! I am going to read up on the Comma operator in JavaScript developer.mozilla.org/en-US/docs/W... do you have any other resources you recomend here?