Consider the following snippet of Javascript:
const getter = (key) => (obj) => obj[key]
const stuff = [{ name: 'Harry', age: 28 }, { name: 'Alice', age: 29 }]
const names = stuff.map(getter('name')) // 'Harry', 'Alice'
Is there a native JS function that does the equivalent of the getter function here?
You could get Reflect.get,
Reflect.get(target, propertyKey)
Reflect.get(target, propertyKey, receiver)
but this does not work as a callback for array methods, because of the wrong paramter order.