I am trying to solve a code challenge where I came across a challenge to chain functions and most of the solutions i could find online were using function.toString and override toString method of function like in the following code to chain add function.
function sum(n) {
var v = function(x) {
return sum(n + x);
};
v.toString = function() {
return n;
};
return v;
}
What does toString do here to replace function call method? and how does toString work here without a bracket like toString()