lovedota
unread,Sep 13, 2011, 4:49:43 AM9/13/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KnockoutJS
Hi I tried this way, and it work fine. But I want to learn new way to
do it with knockout, Is knockout support filter a duplicate item ?
var opt = [
{ name: "Product 5", price: 10 },
{ name: "Product 6", price: 10 },
{ name: "Product 7", price: 20 },
{ name: "Product 8", price: 30 },
{ name: "Product 9", price: 40 }
];
var i = 0, x, count, item;
while (i < opt.length) {
count = 1, item = opt[i], x = i + 1;
while (x < opt.length && (x = opt.indexOf(item, x.price)) !=
-1) {
count += 1;
opt.splice(x, 1);
}
opt[i] = new Array(opt[i], count);
++i;
}
console.log(opt);
Thanks you !