@espressif/rainmaker-base-cdf
    Preparing search index...

    Function shallowClone

    • Performs a shallow clone of a given object or array.

      Type Parameters

      • T

      Parameters

      • obj: T

        The object or array to be shallowly cloned.

      Returns T

      A new shallow-cloned object or array.

      const obj = { a: 1, b: { c: 2 } };
      const clonedObj = shallowClone(obj);
      console.log(clonedObj); // { a: 1, b: { c: 2 } }
      console.log(obj === clonedObj); // false
      console.log(obj.b === clonedObj.b); // true

      This function performs a shallow clone of an object or array, creating a new object with the same properties and values as the original. Nested objects and arrays are not deeply cloned, meaning that the new object will share references to the nested objects and arrays with the original. This is useful when you need to create a copy of an object without modifying the original, but do not need to deeply clone nested objects or arrays.