Abstracting methods - best technique?
Is there any difference between the two following things - assume we have lots of divs -
- $('DIV').each(function() {
- /* some long and complex logic here */
- });
or
- $.fn.myMethod = function() { /* some long and complex logic here */ }
- $('DIV').myMethod();
I'm thinking that maybe the javascript parser has to reparse the long-and-difficult bit each time in the first instance, but not in the second. But maybe they're actually just the same?
Thanks.