2017-05-31 63 views
0

这是的Javascript,SOAP,执行,变量和函数调用

var result = XrmServiceToolkit.Soap.Execute(setStateRequest); 
  1. 只是存储功能到变量,
  2. 执行和存储的返回值到变量,
  3. 或做都?

不幸的是,我无法在互联网上找到有用的东西。看看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的新手,需要理解这是什么。

回答

1

它将函数的返回值存储到变量中。

你的测试函数不工作的原因是因为你没有在测试中返回一个值。

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可以澄清事情有点多

+0

哦,那是我不好。谢谢你的帮助。 :) – user3772108