One my extended example of listing 5.1.11 from the book Secrets of the JavaScript Ninja.
HTML I will use just to call JS:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="/index.js"></script> </head> <body> </body> </html>
JS
Function.prototype.curry = function() { var fn = this, args = Array.prototype.slice.call(arguments); return function () { return fn.apply(this, args.concat(Array.prototype.slice.call(arguments))); }; } function Test(a, b, c) { console.log("Ok I am here and arguments are: " + a + ", " + b + ", " + c + ", ") } testCurry = Test.curry(1, 2, 3); testCurry();
If you look in to console, you will see the result:
Ok I am here and arguments are: 1, 2, 3,