only()

Returns the only value in this collection, or undefined if there is more than one value, or if there are no values in the collection.

On collections

Usage

  • only()

Related

  • one()

    Returns one, arbitrary value from this collection, or undefined if there are none.

  • peek()

    Returns the value at the beginning of a collection, the value that would be returned by shift().