Function toggle

Toggles an item in an array. If it exists, remove it. If it doesn't exist, add it. If the array contains the given value more than once, this function will remove only one occurrence.

  • Type Parameters

    • T

    Parameters

    • array: T[]

      source array

    • item: T

      item to toggle

    Returns T[]