point-free using String.prototype.concat() not working as expected

45 Views Asked by At

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

0

There are 0 best solutions below