JSSM, a JavaScript state machine - the FSM for FSL
    Preparing search index...

    Function find_repeated


    • Lists all repeated items in an array along with their counts. Subject to matching rules of Map. NaN is manually removed because of conflict rules around unique. Because these are compared with === and because arrays and objects never match that way unless they're the same object, arrays and objects are never considered repeats.

      find_repeated<string>([ ]);                     // []
      find_repeated<string>([ "one" ]); // []
      find_repeated<string>([ "one", "two" ]); // []
      find_repeated<string>([ "one", "one" ]); // [ ["one", 2] ]
      find_repeated<string>([ "one", "two", "one" ]); // [ ["one", 2] ]
      find_repeated<number>([ 0, NaN, 0, NaN ]); // [ [0, 2] ]

      Type Parameters

      • T

      Parameters

      • arr: T[]

      Returns [T, number][]