Last active
September 24, 2020 17:08
-
-
Save 101arrowz/07ce01f111dcde6ba6b0077817400f95 to your computer and use it in GitHub Desktop.
Tiny Object.fromEntries Polyfill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.fromEntries = function(entries) { | |
return entries.reduce( | |
function(a, v) { a[v[0]] = v[1]; return a; }, | |
{} | |
); | |
}; | |
// ES6 | |
Object.fromEntries = entries => entries.reduce((a, v) => (a[v[0]] = v[1], a), {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment