【JavaScript】判断数组对象是否存在某项值

var WorkTypeList = [{ 'WorkTypeId': 1, 'WorkTypeName': '企业主要负责人(A证)' },
{ 'WorkTypeId': 2, 'WorkTypeName': '项目负责人(B证)' },
{ 'WorkTypeId': 3, 'WorkTypeName': '专职安全生产管理人员(C证)' }];  
var standardWorkType = [];

$.each(WorkTypeList, function (index1, value1) {
    if (!standardWorkType.find(element => element.WorkTypeId == value1.WorkTypeId)) {
        standardWorkType.push({ 'WorkTypeId': value1.WorkTypeId, 'WorkTypeName': value1.WorkTypeName });
    }
})

 

posted @ 2022-06-24 18:17  智者见智  阅读(404)  评论(0编辑  收藏  举报