过滤列表会崩溃而不会引发错误
Filtering a list crashes without throwing an error
我有这个 google-apps-script 代码,用于获取一些 YT 频道,并过滤其中的一些频道:
var popularChannels = YouTube.Channels.list('id, snippet, statistics', {
id: resultsParentChannelIds.slice(i * 50, (i + 1) * 50)
}).getItems().
filter(
ch =>
((channelIdFilter == "" || ch.id == channelIdFilter)
&& (subCountFilter == "" || ch.statistics.subscriberCount > subCountFilter)
&& (channelLocationFilter == "" || channel.snippet.country == undefined || channel.snippet.country == channelLocationFilter)
&& (channelNegativeLocationFilter == "" || channel.snippet.country == undefined || channel.snippet.country != channelNegativeLocationFilter)));
除最后一个 NegativeLocation 过滤器外,所有过滤器都是 ""
。
但调试器在第一个过滤器后停止,没有写入任何错误。
如何调试或了解问题所在?
您在中途将 currentValue 变量从 ch
更改为 channel
。
var popularChannels = YouTube.Channels.list('id, snippet, statistics', {
id: resultsParentChannelIds.slice(i * 50, (i + 1) * 50)
}).getItems().
filter(
ch =>
((channelIdFilter == "" || ch.id == channelIdFilter)
&& (subCountFilter == "" || ch.statistics.subscriberCount > subCountFilter)
&& (channelLocationFilter == "" || ch.snippet.country == undefined || ch.snippet.country == channelLocationFilter)
&& (channelNegativeLocationFilter == "" || ch.snippet.country == undefined || ch.snippet.country != channelNegativeLocationFilter)));
我有这个 google-apps-script 代码,用于获取一些 YT 频道,并过滤其中的一些频道:
var popularChannels = YouTube.Channels.list('id, snippet, statistics', {
id: resultsParentChannelIds.slice(i * 50, (i + 1) * 50)
}).getItems().
filter(
ch =>
((channelIdFilter == "" || ch.id == channelIdFilter)
&& (subCountFilter == "" || ch.statistics.subscriberCount > subCountFilter)
&& (channelLocationFilter == "" || channel.snippet.country == undefined || channel.snippet.country == channelLocationFilter)
&& (channelNegativeLocationFilter == "" || channel.snippet.country == undefined || channel.snippet.country != channelNegativeLocationFilter)));
除最后一个 NegativeLocation 过滤器外,所有过滤器都是 ""
。
但调试器在第一个过滤器后停止,没有写入任何错误。
如何调试或了解问题所在?
您在中途将 currentValue 变量从 ch
更改为 channel
。
var popularChannels = YouTube.Channels.list('id, snippet, statistics', {
id: resultsParentChannelIds.slice(i * 50, (i + 1) * 50)
}).getItems().
filter(
ch =>
((channelIdFilter == "" || ch.id == channelIdFilter)
&& (subCountFilter == "" || ch.statistics.subscriberCount > subCountFilter)
&& (channelLocationFilter == "" || ch.snippet.country == undefined || ch.snippet.country == channelLocationFilter)
&& (channelNegativeLocationFilter == "" || ch.snippet.country == undefined || ch.snippet.country != channelNegativeLocationFilter)));