看了一段時間關於js原型的知識
在對象數組裡面經常有根據屬性來進行排序的
代碼如下:
Array
var m = {};
for (var i =
for (var k =
if (func(this[i]) < func(this[k])) {
m = this[k];
this[k] = this[i];
this[i] = m;
}
}
}
return this;
}
Array
var m = {};
for (var i =
for (var k =
if (func(this[i]) > func(this[k])) {
m = this[k];
this[k] = this[i];
this[i] = m;
}
}
}
return this;
}
調用的方法如下
代碼如下:
var arr = [{ name:
var orderArr = arr
return a
});
然後輸出一下
代碼如下:
for (var i =
document
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19823.html