Tweakr
    Preparing search index...

    Function identity

    • Returns the given value unchanged.

      This is a simple utility function that can be useful in functional programming contexts or when a placeholder function is needed.

      Type Parameters

      • T

        The type of the input value.

      Parameters

      • value: T

        The value to return.

      Returns T

      The same value that was passed in.

      1.1.0

      const result = identity(42);      // 42
      const obj = { a: 1 };
      const sameObj = identity(obj); // { a: 1 }