const r1 = [1, 2, 3].myReduce((a, c) => a + c); // 6
    const r2 = [1, 2, 3].myReduce((a, c, i, arr) => a + c, 10); // 16
    const r3 = [{ num: 1 }, { num: 2 }, { num: 3 }].myReduce(
      function(a, c) {
        return { ...a, [c.num]: 'hi' };
      },
      {},
    ); // { 1: 'hi', 2: 'hi', 3: 'hi' }
    // Argument of type '{}' is not assignable to parameter of type '{ num: number; }'. Property 'num' is missing in type '{}' but required in type '{ num: number; }'.
    const r4 = [{ num: 1 }, { num: 2 }, { num: 3 }].myReduce(
      function(a, c) {
        return a + c.num;
      },
      '',
    ); // '123'
    // Operator '+' cannot be applied to types '{ num: number; }' and 'number'.
    // Argument of type 'string' is not assignable to parameter of type '{ num: number; }'.
    
    interface Array<T> {
      myReduce(callback: (a: T, c: T, i: number, arr: T[]) => T, iV?: T): T;
    }
    
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.