Picks the key-value pairs corresponding to the given keys from an object.
Use Array.prototype.reduce() to convert the filtered/picked keys back to an object with the corresponding key-value pairs if the key exists in the object.
constpick=(obj, arr)=>
arr.reduce((acc, curr)=>(curr in obj &&(acc[curr]= obj[curr]), acc),{});
Creates an object composed of the properties the given function returns falsy for.
JavaScript, Object · Oct 21, 2020
30 seconds of code uses cookies to provide a high quality user experience
and gather anonymized data for statistical analysis of the website's traffic.
You can learn more by reading our cookie policy. By clicking Accept you accept their installation.