Create a map with the same values ββand keys using the FP method using ES6 / Harmony
Given a set of "Apple", "Banana" and "Orange", create the following:
{ "Apple": "Apple", "Banana": "Banana", "Orange": "Orange" }
that is, each row becomes a key as well as a value.
(That is, by the way, what Facebook has little KeyMirror JS utility does in its Flux examples.)
Is there a functional programming one-liner way using ES6 / Harmony like:
["Apple", "Banana", "Orange"].map(v => v: v)
not as a non-functional programming way, for example:
let o = {}; for (let v of ["Apple", "Banana", "Orange"]) o[v] = v;
+3
source to share