慕盖茨4494581
给你个理解的方式,假如sort函数的代码是这样的:Array.prototype.sort(compareFn){var defaultCompareFn = function(a,b){//(冒泡)排序方式内容};if(!compareFn || typeof compareFn != 'function'){compareFn = defaultCompareFn;}//可能调用的实现方式var ps = [];for(var i=0;i<this.length;i++){ps[i] = compareFn(this[i],this[(i+1)>=this.length?0:(i+1)]);}//....}