this function works in firefox but not in IE8 ? traversing through DOM

this function works in firefox but not in IE8 ? traversing through DOM

the below functions work in firefox but not IE8 any idea why?
it throws the slow script with no end...
  1. $.fn.reverse =
    function () {

    return this.pushStack(this.get().reverse(), arguments);

    };

    // create two new functions: prevALL and nextALL.

    $.each([

    'prev', 'next'], function (unusedIndex, name) {

          $.fn[name +

    'ALL'] = function (matchExpr) {

          // get all the elements in the body, including the body.

          var $all = $('body').find('*').andSelf();

          // slice the $all object according to which way we're looking

          $all = (name ==

    'prev')

                ? $all.slice(0, $all.index(

    this)-10).reverse()

                : $all.slice($all.index(

    this) + 2)

          ;

          // filter the matches if specified

          if (matchExpr) $all = $all.filter(matchExpr);

                return $all;

    };

    });