Author: Not specified Language: javascript
Description: Not specified Timestamp: 2018-05-10 11:35:12 +0000
View raw paste Reply
  1. function sum(x) {
  2.   if (arguments.length == 2) {
  3.     return arguments[0] + arguments[1];
  4.   } else {
  5.     return function(y) { return x + y; };
  6.   }
  7. }
  8.  
  9. console.log(sum(2,3));
  10. console.log(sum(2)(3));
View raw paste Reply