How to get unique values from array in Jquery?
Hi Guys,
In this example,I will learn you how to remove unique values from array in jquery.you can easy and simply remove remove unique values from array in jquery.
So, here i will give you very simple example of jquery get unique values from json array with output.
Example :
<!DOCTYPE html>
<html>
<head>
<title>How to get unique values from array in Jquery? - Nicesnippets.com</title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<script type="text/javascript">
var sites = ["keval","mehul","dharmik","keval"];
var uniqueSites = sites.filter(function(item, i, sites) {
return i == sites.indexOf(item);
});
console.log(uniqueSites);
</script>
</body>
</html>
Output:
["keval","mehul","dharmik"]
It will help you...
- How to Show Loading Spinner in JQuery?
- How to Create Ajax Submit Form Using jQuery?
- How To Get Current Page URL, Path, Host and hash using jQuery?
- How To Get, Set and Delete Div Background Image jQuery?
- JQuery Remove All Unwanted Whitespace From String Example
- Body Background Video Using Vide Jquery Example
- JQuery UI Autocomplete Example
- JQuery Split String By Comma Into Array Example