Function.call Method As Callback
Excuse me if I've something missed, but when I try to use call method as a callback it gives me strange error in both Chrome and Node.js. [' foo', ' bar '].map(String.prototype.t
Solution 1:
The easiest solution to your problem is to just write it out:
[' foo', ' bar '].map(s => s.trim());
If you want to pass a function, you will need something more complicated than you want, along the lines of
.map(Function.call.bind(String.prototype.trim))
or if you prefer
.map(Function.call, String.prototype.trim)
This question may answer all your issues.
Post a Comment for "Function.call Method As Callback"