Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js get each pair of values from an array of objects

function uniquePairs(arr) {
    return arr.flatMap((item1, index1) =>
        arr.flatMap((item2, index2) =>
            (index1 > index2) ? [[item1, item2]] : []
        )
    );
}
Comment

js get each pair of values from an array

function uniquePairs(arr) {
    return arr.reduce((acc, current, i) =>
        [...acc, ...(arr.slice(i + 1).map(val => [current, val]))], []);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to add datepicker in appended input 
Javascript :: jabascript for each 
Javascript :: nestjs optional guard 
Javascript :: node_modules imers-browserifymain.js 
Javascript :: How to create a debounce higher order function 
Javascript :: descomponer un numero js 
Javascript :: javascript intersect two object arrays 
Javascript :: mongo look for substring of field 
Javascript :: redux extension link 
Javascript :: how to manually sort array javascript 
Javascript :: How to make a json call to a URL 
Javascript :: check if element is displayed 
Javascript :: javascript use numbers as objects 
Javascript :: cara install parrot os di virtualbox 
Javascript :: kasthamandap college 
Javascript :: simple form in react native with code 
Javascript :: JSX expression with JS template literals 
Javascript :: react-native-page-control 
Javascript :: how take a item from object javascript 
Javascript :: get react form input using ref react 18 
Javascript :: jquery init dropdown 
Javascript :: find parent index of nested array object javascript 
Javascript :: sum properties some objects when merge their 
Javascript :: Backbone Sync Example 
Javascript :: how to style on-click in react/ vuejs router 
Javascript :: convert snake case to camelcase javascript recursive 
Javascript :: convert javascript to java 
Javascript :: concurrently package usage 
Javascript :: node js swear filter 
Javascript :: oop js 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =