Function assignProps

  • 把源对象的属性复制到目标对象。

    Type Parameters

    • T extends object

    Parameters

    • target: object

      目标对象。

    • Rest...sources: (undefined | null | T)[]

      源对象。如果有多个源对象存在相同属性,则后者覆盖前者。

    Returns T

    目标对象。

    import { assignProps } from '@just4/util';
    assignProps(
    { a: 1, b: 2 },
    { b: 3, c: 4 },
    { b: 5, d: 6 }
    ); // { a: 1, b: 5, c: 4, d: 6 }