ale*_*nco 4 javascript function
我正在阅读本教程:http://nathansjslessons.appspot.com/
里面有一个课程说:
// A simple function that adds one
var plusOne = function (x) {
return x + 1;
};
Run Code Online (Sandbox Code Playgroud)
我习惯看到这样的函数:
function myFunction() {
return x + 1;
};
Run Code Online (Sandbox Code Playgroud)
第一个和第二个之间有什么区别?
唯一的区别是第一个功能:
var plusOne = function (x) { return x + 1; };
在运行时定义,而另一个函数:
function myFunction() { return x + 1; };
在脚本块的解析时定义.