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

    Function simpleClone

    • simple clone, use JSON.parse and JSON.stringify

      简单的克隆,使用 JSON.parse 和 JSON.stringify

      Type Parameters

      • T = any

        The type of elements in the array / 数组元素的类型

      Parameters

      • source: T

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

      Returns T

      The cloned data. 克隆后的数据

      This function uses JSON.parse(JSON.stringify()) which has the following limitations:

      • undefined values, functions, and Symbol keys/values are silently dropped
      • Date objects are converted to ISO strings (not Date instances)
      • RegExp, Map, Set, ArrayBuffer, TypedArray are not properly cloned
      • Circular references will throw a TypeError
      • NaN and Infinity are converted to null

      For full deep cloning support, use deepClone instead.

      此函数使用 JSON.parse(JSON.stringify()),存在以下限制:

      • undefined 值、函数和 Symbol 键/值会被静默丢弃
      • Date 对象会转换为 ISO 字符串(而非 Date 实例)
      • RegExpMapSetArrayBufferTypedArray 无法正确克隆
      • 循环引用会抛出 TypeError
      • NaNInfinity 会被转换为 null

      如需完整的深克隆支持,请使用 deepClone