Jump to content

Search the Community

Showing results for tags 'elimination'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. BACKGROUND: I recently discovered the following piece of code on StackOverflow,. Although it works for a single property comparison, I do not understand it well enough to expand it to cope with multiple properties. function getUnique(inputArr, comp) { const unique = inputArr.map(e => e[comp]).map((e, i, final) => final.indexOf(e) === i && i).filter(e => inputArr[e]).map(e => inputArr[e]); return unique; } I would like to create a function that would permit the comparison of multiple values on the order of function getUnique(inputArr, comp1 [, comp2[, comp3 [...]]]){...} Any suggestions? At minimum could you help with a better understanding of how it does what it does. It maps and filters, but in a manner that I do not comprehend easily enough to manipulate. Roddy PS. A little experimentation came up with the following solution. function getUnique(inputArr, comp1, comp2) { const unique = inputArr.map(e => e[comp1] && e[comp2]) .map((e, i, final) => final.indexOf(e) === i && i) .filter(e => inputArr[e]) .map(e => inputArr[e]); return unique; } It achieves my goal, but a little more understanding is still requested.
×
×
  • Create New...