@corefunc/corefunc
    Preparing search index...

    Function arrayBasicWith

    • Type Parameters

      • T

      Parameters

      • array: T[]

        The array to copy and change.

      • index: number

        The index of the element to change.

      • value: unknown

        The value to set.

      • OptionalsuppressErrors: boolean = true

        Suppress errors if range is incorrect.

      Returns T[]

      A new array with the element at index replaced with value.

      arrayBasicWith

      Change the value of a given index. It returns a new array.

      Incorrect index.

      0.3.62

      const array = [1, 2, 3];
      const index = 2;
      if (index in array) {
      const copy = arrayBasicWith(array, index, 300);
      console.log(array); // [1, 2, 3]
      console.log(copy); // [1, 2, 300]
      }