Function constant

  • Creates a function that returns value.

    Type Parameters

    • T

    Parameters

    • Optional value: T

      The value to return from the new function.

      Optional

    Returns (() => T)

    Returns the new constant function.

      • (): T
      • Returns T

    Since

    5.0.0

    Example

    var objects = times(2, constant({ 'a': 1 }));

    console.log(objects);
    // => [{ 'a': 1 }, { 'a': 1 }]

    console.log(objects[0] === objects[1]);
    // => true