es6 one sentence to judge whether two arrays contain the same element

 In the past, the for loop was laborious and laborious, and one sentence ended the judgment

let microsComArr = ["ROLE_XWGSZZH", "ROLE_XWGSYG_CGDB"];
let rolesArr = ["ROLE_BM_GYS", "ROLE_GYSYG_CGDB"]; 
this.isMicros = microsComArr.some(item => {
  return rolesArr.includes(item);
});

Guess you like

Origin blog.csdn.net/qq_37485170/article/details/128235773