Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript include array value in an object property in an array map some

const adminRoles = ['admin', 'captain'];
//----------------------
 let clientIds = [{id:1, roles: 'captain'}, {id:2, roles: 'pilot'}];
 console.log(  
    adminRoles.some((adminRole) => (clientIds.map(x => x.roles).includes(adminRole)))
 )
 // true
//----------------------
let clientIds = [{id:1, roles: '**spy**'}, {id:2, roles: 'pilot'}];
 console.log(  
    adminRoles.some((adminRole) => (clientIds.map(x => x.roles).includes(adminRole)))
 )
 // false
//----------------------
 
PREVIOUS NEXT
Tagged: #javascript #include #array #object #property #array #map
ADD COMMENT
Topic
Name
9+9 =