【发布时间】:2014-07-03 16:40:02
【问题描述】:
Python 确实内置了函数 any() 和 all(),它们应用于列表(JavaScript 中的数组),如下所示-
any(): Return True if any element of the iterable is true. If the iterable is empty, return False.
all(): Return True if all elements of the iterable are true (or if the iterable is empty).
我们可以为上述创建自定义函数,但如果 JavaScript 中有任何等效的内置函数可用,请告诉我。
【问题讨论】:
-
Array.some(), Array.every()。不过,只有最新版本的 Javascript 支持它们。
标签: javascript python arrays list python-2.7