dimanche 21 août 2016

how to check consecutive objects are same using underscore

var list = [
       {name :a,id:1,index:1},
       {name :a,id:1,index:2},
       {name :b,id:2,index:3},
       {name :c,id:3,index:4},
       {name :b,id:2,index:5},
];

i want to avoid the above situation , here object having name = a

coming twice consecutively. But whereas object having name = b

is acceptable

i expect some buil it funtion which will find these type of objects. just like isNaN

tried with plain javascript but need function in underscore.

Aucun commentaire:

Enregistrer un commentaire