的Javascript,SOAP,执行,变量和函数调用
问题描述:
var result = XrmServiceToolkit.Soap.Execute(setStateRequest);
- 只是存储功能到变量,
- 执行和存储的返回值到变量,
- 或做都?
不幸的是,我无法在互联网上找到有用的东西。看看http://xrmservicetoolkit.codeplex.com/wikipage?title=Soap%20Functions 它看起来像功能执行,但我不知道。
我也与Chrome浏览器中正常的Javascript测试,并得到这样的结果:
> function test(a){
console.log(a);
};
undefined
调用函数正常
> test("asd");
asd
随着变量声明
> var x = test("asd");
asd
但它看起来像变量不包含任何信息
> console.log(x);
undefined
> x
undefined
现在我完全困惑了。为什么函数在从未被存储时称为变量?我是Javascript的新手,需要理解这是什么。
答
它将函数的返回值存储到变量中。
你的测试函数不工作的原因是因为你没有在测试中返回一个值。
function test(num) {
return num * 2;
}
var doubled = test(2);
// doubled now contains 4
var doubleVariable = test;
// doubleVariable is now the same as test
doubleVariable(2)
// returns 4
这article可以澄清事情有点多
哦,那是我不好。谢谢你的帮助。 :) – user3772108