开发者

Difference between functions and function literals in ActionScript 3?

开发者 https://www.devze.com 2023-03-19 15:31 出处:网络
What is the difference between the following two function definitions in ActionScript 3? f = function(arg) {

What is the difference between the following two function definitions in ActionScript 3?

f = function(arg) {
  // body
}

开发者_StackOverflowand

function f(arg) {
  // body
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消