Tod*_*nce 0 javascript anonymous-function
var destURL = function () {
if (this.typeOfDash == 'edit') {
return '../../ajax/getParams.aspx';
}
else {
return 'DashCreator.aspx';
}
Run Code Online (Sandbox Code Playgroud)
}
我希望这会工作,但它只是将函数分配给变量...我希望得到返回值作为变量值...任何人?
您可以立即评估函数以获取返回值.
var destURL = function () {
if (this.typeOfDash == 'edit') {
return '../../ajax/getParams.aspx';
}
else {
return 'DashCreator.aspx';
}
}()
Run Code Online (Sandbox Code Playgroud)