Skip to main content

EtchEmKay

Member since Sep 10, 2010

Recent Blog Comments By EtchEmKay

  • Overloading Javascript Functions Using A Sub-Function Approach

    Posted on Sep 10, 2010 at 6:23 AM

    A (very) quick prototype of a cleaner way of doing (strict) arguments check for both - type and count - Function.prototype.overload = function () { this.variants = this.variants || {}; var len = arguments.length, args = (Array.prototype.slice.call(arguments)), id = args.slice(0,le... read more »

  • Overloading Javascript Functions Using A Sub-Function Approach

    Posted on Sep 10, 2010 at 1:51 AM

    Oops .. the comment in the last line of code above should read "calls the 2-param version" .. which I think is a better implementation considering that the randRange() function essentially wants to deal with maximum of 2 arguments .. any more should be ignored.... read more »

  • Overloading Javascript Functions Using A Sub-Function Approach

    Posted on Sep 10, 2010 at 1:43 AM

    Another way of doing it (shorter version) - function randRange(){ (randRange[arguments.length] || randRange[2]).apply(this, arguments); } randRange[0] = function () { alert('Error: No parameters passed!'); return 0; }; randRange[1] = function (max) { return( randRange[2]( 0, max ) )... read more »

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel