【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 }); } })
搜索
复制
<iframe height="240" width="320"></iframe>标签:JavaScript,数组,WorkTypeId,某项,WorkTypeName,var,value1,WorkTypeList,standardWorkTyp 来源: https://www.cnblogs.com/zhaoyl9/p/16409879.html