判断一个对象数组中某一项是否某一个值?
1 const data = [{ 2 name: "撤回", 3 type: "withdraw" 4 }, { 5 name: "...", 6 type: "other", 7 children: [{ 8 name: "会签", 9 type: "sign" 10 }] 11 }]; 12 13 const exist = data.some(item => item.type.indexOf('sign') > -1);
打印结果:
true