@pengzhanbo/utils - v3.7.3
    Preparing search index...

    Function shallowClone

    • shallow clone, only clone the first level

      浅克隆,只克隆第一层

      Type Parameters

      • T = any

      Parameters

      • source: T

        The source data to clone. 要克隆的源数据

      Returns T

      The cloned data. 克隆后的数据

      This function preserves the prototype chain and handles Date, Map, Set, RegExp, Error, and File objects specifically by constructing new instances from the originals. Arrays, TypedArrays, ArrayBuffer, and SharedArrayBuffer are cloned via .slice(). Plain objects are cloned via Object.assign with the prototype preserved.

      此函数会保留原型链,并针对 Date、Map、Set、RegExp、Error 和 File 对象进行特殊处理,通过构造新实例来完成克隆。数组、TypedArrays、ArrayBuffer 和 SharedArrayBuffer 通过 .slice() 克隆。普通对象通过 Object.assign 克隆并保留原型。