Just to make this post more constructive for everyone, jdalton included // if function name is not a problem (184K over 100000) jQuery.ajaxSettings.ext = (function(anonymous){ return function(o){ anonymous.prototype = this.data || {}; var k, result = new anonymous; if(o){ for(k in o) result[k] = o[k] ; }; return result; }; })(Function());
// if we want the function name avoiding scope leaks (184K over 100000) jQuery.ajaxSettings.ext = (function(anonymous){ function ext(o){ anonymous.prototype = this.data || {}; var k, result = new anonymous; if(o){ for(k in o) result[k] = o[k] ; }; return result; }; return ext; })(Function()); // if we want the function name writing less code (dbl ref: 202K over 100000) // or simply if we quickly suggested a solution in a ml for a single iteraction // memory 1.1X jQuery.ajaxSettings.ext = (function(anonymous){ return function ext(o){ anonymous.prototype = this.data || {}; var k, result = new anonymous; if(o){ for(k in o) result[k] = o[k] ; }; return result; }; })(Function()); // if we want test IE Scope Resolution way (187K over 100000) // 'cause one day there could be more than a function // with same name in the same scope and not because // we need it // memory 1.01X but so far it's only way to have right references in IE jQuery.ajaxSettings.ext = (function(anonymous){ var ext = function ext(o){ anonymous.prototype = this.data || {}; var k, result = new anonymous; if(o){ for(k in o) result[k] = o[k] ; }; return result; }; return ext; })(Function()); // if we want test IE Scope Resolution way (187K over 100000) // using an IE specific behavior that wont define // anything global since we understood IE Scope Resolution // and we use this shorter code only in IE jQuery.ajaxSettings.ext = (function(anonymous){ return ext = function ext(o){ anonymous.prototype = this.data || {}; var k, result = new anonymous; if(o){ for(k in o) result[k] = o[k] ; }; return result; }; })(Function()); This is pretty much it, still my fault I chose the third snippet, I could not imagine all this effort for 3 lines of code, I wonder why there is not the same effort for every single piece of whatever library. Regards --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---