Pointfree Javascript
December 10, 2015
Pointfree Javascript In a recent post Functional Javascript, we talked about using functions to simplify our coding practice. I would like to dig in a bit more and talk about pointfree. Pointfree is a function that doesn't know what its data is. For example: // Not Pointfree var initials = function (name) { return name.split(' ').map(R.compose(R.toUpper, R.head)).join('. '); }; //pointfree var initials = R.compose(R.join('. '), R.map(R.compose(R.toUpper, R.head)), R.split(' ')); Notice our first function takes in a parameter of name, because it knows its data it is not pointfree. Our second function does the same as the first but doesn't know its data. Therefore, it is pointfree. For some, the second function is foreign and confusing and the first is something closer to what you might be used to seeing. However, even the first could be confusing, what is compose, how…