2017-05-31 20 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