Javascript currying
Please explain me this code and also what is this !! means and arguments. callee var currying = function(fn) { var args = []; return function() { if (!!arguments.length) { [].push.apply(args, arguments); // What's the meaning of this writing? return arguments.callee; } else { return fn.apply(this, args); } } } // accumulation currying var sum = (function(num){ var ret = 0; return function(){ for(var i = 0, len = arguments.length; i < len; i++) { ret += arguments[i]; } return ret; } })(); var newSum = currying(sum); newSum(1)(2)(3)(4)() // 10 // element find currying var find = function(arr, el){ return arr.indexOf(el) !== -1; } var newFind = currying(find)([1,2,3]); newFind(1); newFind(2);