setTimeout(function() { return function() { console.log("setTimeout"); };}(), 500);function test(){ return function() { console.log("test"); };}test();上述執行結果為setTimeout。test函數里邊的console語句不執行很容易理解,返回一個函數但沒有調用它,所以不執行,也就不會輸出test。不過setTimeout里邊函數在500ms后執行,也是返回一個函數,怎么就執行了,誰調用的它呢?求教
js setTimeout中return 函數如何自己執行的?
智慧大石
2018-09-04 13:10:15