ActionScript 3 中函数和函数文字之间的区别?
ActionScript 3 中以下两个函数定义有什么区别?
f = function(arg) {
// body
}
和
function f(arg) {
// body
}
What is the difference between the following two function definitions in ActionScript 3?
f = function(arg) {
// body
}
and
function f(arg) {
// body
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提供的示例几乎没有实际差异。区别实际上是在编译时。值得注意的是,在第一种情况下,f = function,您可以随时重新定义f的值,而在第二种情况下,重新定义f会导致编译器错误。
一般最佳实践是使用第二种。
希望有帮助。
There is very little practical difference in the example you have provided. The difference is really at compile time. The one worth noting is that that in first case, f = function, you can redefine the value of f at anytime, while in the second case, redefining f would cause a compiler error.
General best practices is to use the second.
Hope that helps.