• 模拟Function.prototype.apply函数代替扩展运算符,使用数组传值给不定参数的函数传参

    案例 const args = [1, 2, 3]; (new Function(generateFunctionCode(args.length)))(object, property, args);

    类型参数

    • T extends object
    • K extends string | number | symbol

    参数

    • obj: T
    • property: K
    • args: any[]

    返回 any

    '123'.padStart(6, '0'); // '000123'
    const value = functionApply(
    { strPadStart: (s: string, count: number, pad: string) => s.padStart(count, pad) },
    'strPadStart',
    ['123', 6, '0'],
    );
    value; // '000123'
""