前端JS:判断list(数组)中的json对象是否重复
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<script>
function displayDate(){
var arr = [{ d: '2015-10-12',C:'Apple'}, { d: '2015-10-12',C:'Apple'}, { d: '2015-10-13',C :'Apple' }];
var find = false;
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i].d == arr[j].d && arr[i].C==arr[j].C) { find = true; break;}
}
if (find) break;
}
alert(find)
}
</script>
</head>
<body>
判断list中的json对象是否重复
<button type="button" onclick="displayDate()">是否重复</button>
</body>
</html>