js 遍历数组对象 根据属性值 生成新的数组对象
[
{
"clockInState": 0,
"sectionNum": "1",
"courseBegin": "2019-02-09 00:00:00.0",
"teacherName": "老师",
"drillID": 0,
"childList": [
{
"clockInState": 0,
"sectionNum": "1",
"courseBegin": "2019-02-09 00:00",
"teacherName": "老师",
"drillID": 0,
"childList": [
{
"clockInState": 0,
"sectionNum": "1",
"courseBegin": "2019-02-09 00:00",
"teacherName": "老师",
"drillID": 0,
"sectionId": 145,
"sectionLevel": "3",
"parentId": 131,
"content": "章节看到了吗",
"sectionName": "疾病类型",
"courseDrillId": 10,
"userSectionStats": 0,
"courseCover": "courseCover/courseCover预防感冒1547003167675.png"
}
],
"sectionId": 131,
"sectionLevel": "2",
"parentId": 55,
"content": "day1内容",
"sectionName": "day1",
"courseDrillId": 10,
"userSectionStats": 1,
"courseCover": "courseCover/courseCover预防感冒1547003167675.png"
}
],
"sectionId": 55,
"sectionLevel": "1",
"parentId": 0,
"content": "结合流行病学史、临床表现",
"sectionName": "诊断",
"courseDrillId": 10,
"userSectionStats": 1,
"courseCover": "courseCover/courseCover预防感冒1547003167675.png"
},
{
"clockInState": 0,
"sectionNum": "2",
"courseBegin": "2019-02-09 00:00:00.0",
"teacherName": "老师",
"drillID": 0,
"childList": [
{
"clockInState": 0,
"sectionNum": "14",
"courseBegin": "2019-02-22 00:00",
"teacherName": "老师",
"drillID": 0,
"childList": [
{
"sectionName": "打吊针",
"clockInState": 0,
"sectionNum": "1",
"courseDrillId": 10,
"courseBegin": "2019-02-22 00:00",
"teacherName": "老师",
"drillID": 0,
"userSectionStats": 0,
"sectionId": 210,
"sectionLevel": "3",
"courseCover": "courseCover/courseCover预防感冒1547003167675.png",
"parentId": 209
}
],
"sectionId": 209,
"sectionLevel": "2",
"parentId": 207,
"sectionName": "day1",
"courseDrillId": 10,
"userSectionStats": 1,
"courseCover": "courseCover/courseCover预防感冒1547003167675.png"
},
{
"clockInState": 0,
"sectionNum": "15",
"courseBegin": "2019-02-23 00:00",
"teacherName": "老师",
"drillID": 0,
"childList": [
{
"sectionName": "吃西药",
"clockInState": 0,
"sectionNum": "1",
"courseDrillId": 10,
"courseBegin": "2019-02-23 00:00",
"teacherName": "老师",
"drillID": 0,
"userSectionStats": 0,
"sectionId": 402,
"sectionLevel": "3",
"courseCover": "courseCover/courseCover预防感冒1547003167675.png",
"parentId": 236
}
],
"sectionId": 236,
"sectionLevel": "2",
"parentId": 207,
"sectionName": "day2",
"courseDrillId": 10,
"userSectionStats": 1,
"courseCover": "courseCover/courseCover预防感冒1547003167675.png"
}
],
"sectionId": 207,
"sectionLevel": "1",
"parentId": 0,
"content": "undefined",
"sectionName": "治疗",
"courseDrillId": 10,
"userSectionStats": 1,
"courseCover": "courseCover/courseCover预防感冒1547003167675.png"
}
]
有这样一个结构的数组对象 和 如下结构的一维数组
const teachers = ['张三', '李四' …]
现在希望遍历数组对象,通过比对 teacherName 属性是否在 teachers 中存在,得到一个新的数组对象
遍历方法怎么写 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
结果