4 ms·
Over.js - Elegant function overloading in JavaScript
over.js formalizes the way we write overloaded functions, so there's no more chunky switch cases and argument.length checks inside every function. What do you guys think?
- matryer 13y agovar obj = { /** * Says something in the console. * * say(msg) - Says something once. * say(msg, times) - Says something many times. */ say: Over( function(msg$string){ console.info(msg$string); }, function(msg$string, times$number){ for (var i = 0; i < times$number; i++) this.say(msg$string); } ) };
- stigoalie31 13y agoVery clever!