how to make this syntax possible in node.js console (javascript) -


this question has answer here:

the same function summ :

summ(7)(3)(5) must equal 15

and

summ(7)(3)+5 must equal 15

and

summ(7)(3) must equal 10

how make possible?

you can use tostring/valueof method treat result value.

function sum(a) {   chain.valueof = function() {return a;}   return chain;    function chain(s) {     += s;     return chain;   }; }  sum(7)(3)(5)  == 15  // true sum(7)(3) + 5 == 15  // true +sum(7)(3)(5)        // 15 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -