DEV Community

Discussion on: Extending the Array map() function

Collapse
 
sly1024 profile image
Szilveszter Safar • Edited

Or you can do:

_ = new Proxy({}, { get: (t, prop) => (obj) => obj[prop] });
call = new Proxy({}, { get: (t, prop) => (obj) => obj[prop]() });

arr = [{ a: 1, b: 2}, { a: 3, b: 4}];
arr.map(_.a) // [1, 3]
arr.map(_.b) // [2, 4]
arr.map(call.toString) // ["[object Object]", "[object Object]"]
Enter fullscreen mode Exit fullscreen mode