Skip to content

Arrow functions · ⁨箭头函数⁩

English

Arrow functions

  • A shorter way to write a function: const square = (n) => n * n;.
  • With a single expression after =>, the value is returned automatically — no return, no { }.

中文

箭头函数

  • 一种更简短的函数写法:const square = (n) => n * n;。
  • 当 => 后面只有一个表达式时,它会自动返回 —— 不用 return,也不用 { }。

同一个函数的两种写法:完整写法,和简短的箭头写法

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩