Imagine a scenario where I have the following code:
const a = val => val;
const b = [a];
const results = b.map(fn => fn('x'));
I am eager to find a solution that avoids creating an extra function in the map method. I want to achieve the same results in a more concise way, even if it means sacrificing the ability to pass a parameter.
const results = b.map(Function.call); // Attempted solution
However, when I try this in Chrome console, I encounter the following error message:
VM1075:3 Uncaught TypeError: undefined is not a function
I also experimented with:
const results = b.map(Function.prototype.call);
1) What is causing this error and why is it not working?
2)
What steps can I take to fix this issue?
Is there a way to always pass the same parameter while fixing the problem? (Perhaps something like Function.call.bind(this, 'param'))