@pengzhanbo/utils - v3.12.0
    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 by copying their own enumerable properties onto a fresh object with the prototype preserved; an own __proto__ key is dropped.

      此函数会保留原型链,并针对 Date、Map、Set、RegExp、Error 和 File 对象进行特殊处理,通过构造新实例来完成克隆。数组、TypedArrays、ArrayBuffer 和 SharedArrayBuffer 通过 .slice() 克隆。普通对象通过复制自有可枚举属性到新对象来克隆并保留原型;自有的 __proto__ 键会被丢弃。