I have an array of objects
var arr = [{ name: 'ABC', class: 'A', section:'1', roll_no: '123' },
{ name: 'xyz', class: 'A', section:'1', roll_no: '456' },
{ name: 'AKM', class: 'B', section:'2', roll_no: '333' },
{ name: 'PQR', class: 'A', section:'1', roll_no: '444' },
{ name: 'STU', class: 'B', section:'2', roll_no: '533' },
{ name: 'JKL', class: 'B', section:'2', roll_no: '987' }];
Here you can see I am having class
and section
, I want to find distinct class
and section
values.
For example, I want to get 2 classes A and B and 2 section 1 and 2.
How can I get the distinct values in a different array?
Thanks.
EDIT
The output I am expecting is :
var output = [{ class: 'A', section:'1'},
{ class: 'B', section:'2'}
];
This is not a duplicated question I am not using underscore js.