Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created May 9, 2019 10:37
Show Gist options
  • Save ThaddeusJiang/861454369b827427141bdcefb9f11ef9 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/861454369b827427141bdcefb9f11ef9 to your computer and use it in GitHub Desktop.
[JS] When to use function ?

什么时候使用函数声明?

Never

别打我,不是我说的,《JavaScript 精粹》中说的。

函数声明,作用域提升和 this 绑定等问题。

变量函数缺没有这种问题,爽歪歪。

对于匿名函数

// 两种方法是一样的。
// 当然更推荐箭头函数,因为可以少敲击几下键盘,省力。
() => {

}

function() {

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment