Skip to main content

Command Palette

Search for a command to run...

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

Published
1 min readView as Markdown
D
I created SWC, an open-source compiler project, and previously worked at Deno and Vercel. These days, I spend a lot of time building Labor0, along with Watchtower and The AI Platform at Zephyr Cloud IO.

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

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

var a,
  b = true,
  c;

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

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

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

More from this blog