Push Unique Values to an Array

How to Push Unique Values to an Array


data.d.results is the given array and it will push only unique column values to an array.


var UnArr = [];

$.each(data.d.results, function(key, value) {
if ($.inArray(value.Title, UnArr) === -1) {
UnArr .push(value.Title);
}
});

The output UnArr [] Array will have only unique values now.

Comments

Popular posts from this blog

How to Customize exported excel's cell background color in Datatables

Populate dropdown using jquery ajax in SharePoint

Clear DataTable on button click