Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript unique grouped arrays

let user = {
  id: 12345,
  aCaption: { teams: ["111", "222", "444"] },
  bCaptain: { teams: ["444", "222", "111", "444"] }
};

let userA = user.aCaptain?.teams ?? []; // 111, 222, 444
let userB = user.bCaptain?.teams ?? []; // 444, 222, 111, 444

let userAllUniqueTeams = [...new Set([...userA, ...userB])]; // 111, 222, 444
Comment

PREVIOUS NEXT
Code Example
Javascript :: Context: Cannot read properties of undefined 
Javascript :: How to make notifications vibrate phone react native expo 
Javascript :: .push( ) is not updating the variable 
Javascript :: socket io check send 
Javascript :: How to check the increase/decrease of letter input in pasting clipboard in jQuery 
Javascript :: Render JOSN in frontend 
Javascript :: settimeout and create directory nodejs 
Javascript :: fetch 500 internal server error 
Javascript :: How do I group values to an array for the same field value in jq 
Javascript :: style dropdown react native picker 
Javascript :: select the value of dropdownMenu with Semantic ui react 
Javascript :: Using Bind() With BuiltIn JavaScript Function 
Javascript :: varibale as listeneres javascirpit 
Javascript :: Exporting And Importing From A Module 
Javascript :: Create A Class Using JavaScript 
Javascript :: javascript object access time complexity 
Javascript :: Accessing Our CryptoCurrency blockchain through local server 
Javascript :: wait for element to be loaded 
Javascript :: map sord elo 
Javascript :: Download A File With Link Using ExpressJS 
Javascript :: Declaring A Method Outside The Constructor 
Javascript :: general hardhat config js file code 
Javascript :: react mui pagination change text color site:stackoverflow.com 
Javascript :: use function in mongodb query example 
Javascript :: use spread operator in max method javascript 
Javascript :: dockerignore node_modules 
Javascript :: screen orientation and width&height 
Javascript :: js pipe 
Javascript :: javascript last value of array 
Javascript :: invalid json response body 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =