I am reading about the 30s of code in JavaScript and find the following code in adapter chapter. I did not quite understand how this code snippets bind the map and the callback function to the context. Could someone help in explaining this?
const call = (key, ...args) => (context) => context[key](...args);
Promise.resolve([1, 2, 3])
.then(call('map', x => 2 * x))
//Does it mean [1,2,3][map](x=> 2*x)? How does this work?
.then(console.log);
// [ 2, 4, 6 ]