javascript - Get all duplicate values from object array -
i have following object deserialised json data
[{ "employeenumber": "169", "employeenumbererror": "", "employeefirstname": "saj" }, { "employeenumber": "169", "employeenumbererror": "", "employeefirstname": "carlton" }, { "employeenumber": "1002", "employeenumbererror": "", "employeefirstname": "stanley" }]
i want duplicate 'employeenumber' object using javascript or jquery. can 1 me?
try this
$(document).ready(function() { var v = [{ "employeenumber": "169", "employeenumbererror": "", "employeefirstname": "saj" }, { "employeenumber": "169", "employeenumbererror": "", "employeefirstname": "carlton" }, { "employeenumber": "1002", "employeenumbererror": "", "employeefirstname": "stanley" }]; var = []; (x = 0; x < v.length; x++) { (y = 0; y < v.length; y++) { if (v[x].employeenumber == v[y].employeenumber) { a.push(v[x].employeenumber) } } } = jquery.unique(a); alert(a[1]); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Comments
Post a Comment