I got an unexpected behavior when I try to concat two strings in a point-free style:
const namespace = "ns-";
const names = ['bar','foo', 'baz'];
names.map((i) => namespace.concat(i)) // ok
names.map(namespace.concat) // ERROR: String.prototype.concat called on null or undefined
I thought I could omit the parameter on function call since AFAIK a => fn(a)
is the same as calling fn
. But in the case of using concat() it is not working.
Obviously, I'm missing something on the language, but I don't know what it is
You can't do this, as the map function passes a value out of it, where js thinks 'namespace' is the parameter. So js is call.concat on nothing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.