问题
They say V8 engine is a proper Javascript ES5 engine. Does it support ES5 features like Promise?
回答1:
Apps script V8 recognizes the new function definition formats, for example:
let letAsyncFunction = async function() { //Your logic here }
It asynchronously returns the result of the function evaluations, pretty much like a Promise.
In other words, when the function async is called, it returns a promise. Also await is used for calling an async function and wait for it to resolve or reject
References:
- async function
- V8 runtime Overview
回答2:
No. Promises are not functionally supported. But all promises related syntax doesn't throw any errors. However everything runs synchronously.
async function promise1_() {
Logger.log("Start")
Utilities.sleep(10000);
return "done";
}
function test1(){
promise1_();
Logger.log("End")
}
If promises worked, "End" should be logged before "Start", but that's not the case.
来源:https://stackoverflow.com/questions/61578224/does-google-apps-script-v8-engine-support-promise