Google apps script 如何根据条件终止应用程序脚本执行

Google apps script 如何根据条件终止应用程序脚本执行,google-apps-script,Google Apps Script,我在应用程序脚本程序中有以下内容: // get all email threads that match label from Sheet var threads = GmailApp.search ("label:" + label); 因为我将已处理的线程移动到另一个标签,所以有时我没有未处理的线程。如果没有要处理的线程,如何终止执行?这对您有效吗 if (!threads || threads.length < 1) { return; } if(!threads

我在应用程序脚本程序中有以下内容:

// get all email threads that match label from Sheet
 var threads = GmailApp.search ("label:" + label);

因为我将已处理的线程移动到另一个标签,所以有时我没有未处理的线程。如果没有要处理的线程,如何终止执行?

这对您有效吗

if (!threads || threads.length < 1) {

    return;

}
if(!threads | | threads.length<1){
返回;
}