January 2019
Beginner
210 pages
4h 47m
English
We explored a few potential ways to implement partial application earlier in this chapter. However, we avoided an alternative implementation that uses the function.prototype.bind method. We have done this because the bind method was unsafe in TypeScript versions prior to the 3.2 release. If we install TypeScript version 3.2 or higher, and we enable the strictBindCallApply compilation flag in the tsconfig.json file, we will be able to use bind as follows:
const replace = (s: string, f: string, r: string) => s.split(f).join(r);const replaceForwardSlash = replace.bind(replace, "/");const replaceForwardSlashWithDash = replaceForwardSlash.bind(replaceForwardSlash, "-");replaceForwardSlashWithDash("13/feb/1989");
As we can see, ...
Read now
Unlock full access