Skip to main content

Til: 화살표 함수는 익명함수가 아니다

Published 1 min readMarkdown

흔히들 화살표 함수를 익명함수라고하는데, 화살표 함수에도 .name 속성이 있다.

아래는 바벨 테스트 케이스에서 가져온 코드다.

var a,
  b = true,
  c;

a ||= () => {};
b &&= () => {};
c ??= () => {};

expect(a.name).toBe("a");
expect(b.name).toBe("b");
expect(c.name).toBe("c");

이를 보면 함수 이름 추론이 화살표 함수에도 적용된다는 걸 알 수 있다.

About the author

  • CEO of Delino. I created SWC, an open-source compiler project, and previously worked at Deno and Vercel.

No comments yet. Be the first to comment.

More from this blog