Skip to content

Conversation

@waitingsong
Copy link
Contributor

使用 const 代替 var。
函数内定义函数应使用赋值方式。

@ruanyf
Copy link
Owner

ruanyf commented Nov 9, 2017

函数体内部再定义一个函数,没有问题的。

@ruanyf ruanyf merged commit 5adf73b into ruanyf:gh-pages Nov 9, 2017
@waitingsong
Copy link
Contributor Author

函数嵌套定义一直都是可行的,但现在不建议这么做了。其中一个问题是若在 if/else 分支中使用function声明,那么逻辑上是混淆的,也可能导致未知错误。
所以现在推荐的做法是 : function声明用于 top 顶层的函数定义。函数或者方法内使用变量赋值方式定义函数。

@waitingsong waitingsong deleted the promise branch November 9, 2017 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants