두 객체의 속성을 보면 typerace가 동일합니다. nameage는 서로 다릅니다. 이럴 때 함수를 사용해 중복된 부분을 제거할 수 있습니다.

    자바스크립트

    const personFactory = (name, age) => ({
      type: 'human',
      race: 'yellow',
      name,
      age,
    })
    const person1 = personFactory('zero', 28);
    const person2 = personFactory('nero', 32);
    
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.