Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var add = (function() {
  2.     var consoleLog = console.log,
  3.         result = 0;
  4.    
  5.     function addition( n ) {
  6.         result += n;
  7.         return addition;
  8.     }
  9.    
  10.     addition.getValue = function() {
  11.         return result;
  12.     };
  13.    
  14.     console.log = function( obj ) {
  15.         if (obj == addition) {
  16.             consoleLog( obj.getValue() );
  17.         } else {
  18.             consoleLog( obj );
  19.         }
  20.     };
  21.    
  22.     return addition;
  23. }());
  24.  
  25. console.log( add( 1 )( 2 )( 3 ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement