Last active
August 24, 2020 14:07
-
-
Save flashspys/23c32246e99652996b42b808f026e3e0 to your computer and use it in GitHub Desktop.
MapTo
This file contains 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
const handler = { | |
get: function(_, prop) { | |
return (obj) => { | |
return obj.map((entry) => entry[prop]); | |
} | |
} | |
}; | |
const MapTo = new Proxy({}, handler); | |
// An array of objects. | |
const objects = [{id: 1, name: "Foo"}, {id: 2, name: "Bar"}, {id: 3, name: "Soo"}, {id: 4, name: "Noo"},] | |
console.log("huhu", objects |> MapTo.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment