"平时" JavaScript中的函数与函数变量 [英] "Usual" functions vs function variables in JavaScript
本文介绍了"平时" JavaScript中的函数与函数变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Is there any difference between
function MyFunc() {
// code...
}
和
var MyFunc = function() {
// code...
};
?
推荐答案
本文可能会回答您的问题: JavaScript函数声明模糊。
This article might answer your question : JavaScript function declaration ambiguity.
只有第一个是实际的函数声明,而速记方法只是一个常规变量声明,并将匿名函数指定为它的值。
Only the first one is an actual function declaration, whereas the shorthand method is just a regular variable declaration with an anonymous function assigned to it as its value.
(看一下评论,也可能会得到一些有用的信息)
这篇关于"平时" JavaScript中的函数与函数变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文